From 1a45d21c3c5574e7296ab9b74373a3075a2748b8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Wed, 30 Mar 2011 11:40:58 +0000
Subject: [PATCH] That script was responsible for setting [None] as site list
 on ingested documents. Refactor it a little to do costly things inside the
 cached method

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@44792 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../ERP5Site_getPersonCareerDict.xml          | 26 +++++++++----------
 bt5/erp5_base/bt/revision                     |  2 +-
 2 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/ERP5Site_getPersonCareerDict.xml b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/ERP5Site_getPersonCareerDict.xml
index 2d0a090d99..3ef084bb6c 100644
--- a/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/ERP5Site_getPersonCareerDict.xml
+++ b/bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/ERP5Site_getPersonCareerDict.xml
@@ -56,29 +56,27 @@
 \n
 from Products.ERP5Type.Cache import CachingMethod\n
 \n
-portal = context.getPortalObject()\n
-result = {\'group_list\': [],\n
-          \'site_list\': [],\n
-          }\n
-person = portal.ERP5Site_getAuthenticatedMemberPersonValue(user_name=user_name)\n
-if person is None:\n
-  return result\n
+def getPersonCareerDict(user_name):\n
+  portal = context.getPortalObject()\n
+  result = {\'group_list\': [],\n
+            \'site_list\': [],\n
+            }\n
+  person = portal.ERP5Site_getAuthenticatedMemberPersonValue(user_name=user_name)\n
+  if person is None:\n
+    return result\n
 \n
-def getPersonCareerDict(username):\n
-  person = portal.restrictedTraverse(person_relative_url)\n
   group = person.getGroup()\n
   organisation = person.getSubordinationValue()\n
   if group is not None:\n
-    result[\'group_list\']=[group]\n
+    result[\'group_list\'] = [group]\n
   if organisation is not None:\n
-    result[\'site_list\']=[organisation.getSite()]\n
+    result[\'site_list\'] = organisation.getSiteList()\n
   return result\n
 \n
-person_relative_url = person.getRelativeUrl()\n
 getPersonCareerDict = CachingMethod(getPersonCareerDict,\n
                                     ("ERP5Site_getPersonCareerDict",),\n
-                                    cache_factory=\'erp5_ui_short\')\n
-return getPersonCareerDict(person_relative_url)\n
+                                    cache_factory=\'erp5_content_short\')\n
+return getPersonCareerDict(user_name)\n
 </string> </value>
         </item>
         <item>
diff --git a/bt5/erp5_base/bt/revision b/bt5/erp5_base/bt/revision
index aa5bea4ec6..218241b578 100644
--- a/bt5/erp5_base/bt/revision
+++ b/bt5/erp5_base/bt/revision
@@ -1 +1 @@
-965
+966
\ No newline at end of file
-- 
2.30.9