[Erp5-report] r11305 - in /erp5/trunk/bt5/erp5_dms: SkinTemplateItem/portal_skins/erp5_dms/...
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Nov 15 12:11:13 CET 2006
Author: bartek
Date: Wed Nov 15 12:11:10 2006
New Revision: 11305
URL: http://svn.erp5.org?rev=11305&view=rev
Log:
improved implementation of getting title of related object only if the user can access the object (adviced by Romain)
Modified:
erp5/trunk/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/Base_getRelatedObjectTitle.xml
erp5/trunk/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/Base_getRelatedObjectTitleList.xml
erp5/trunk/bt5/erp5_dms/bt/revision
Modified: erp5/trunk/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/Base_getRelatedObjectTitle.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/Base_getRelatedObjectTitle.xml?rev=11305&r1=11304&r2=11305&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/Base_getRelatedObjectTitle.xml (original)
+++ erp5/trunk/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/Base_getRelatedObjectTitle.xml Wed Nov 15 12:11:10 2006
@@ -68,18 +68,12 @@
</item>
<item>
<key> <string>_body</string> </key>
- <value> <string encoding="cdata"><![CDATA[
-
+ <value> <string># get related object title in a security-aware way (without throwing exception\n
+# if I don\'t have permissions to access the object)\n
cat_value=context.getProperty(category)\n
-res=context.portal_catalog(relative_url=cat_value)\n
-count=len(res)\n
-if count==0:return \'\'\n
-if count>1:\n
- context.log(\'detected %d objects for %s relation\' % (count,category),context)\n
-return res[0].getTitle()\n
-
-
-]]></string> </value>
+ob=context.restrictedTraverse(cat_value,None)\n
+return ob is not None and ob.getTitle() or \'\'\n
+</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
@@ -131,10 +125,8 @@
<string>_getattr_</string>
<string>context</string>
<string>cat_value</string>
- <string>res</string>
- <string>len</string>
- <string>count</string>
- <string>_getitem_</string>
+ <string>None</string>
+ <string>ob</string>
</tuple>
</value>
</item>
Modified: erp5/trunk/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/Base_getRelatedObjectTitleList.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/Base_getRelatedObjectTitleList.xml?rev=11305&r1=11304&r2=11305&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/Base_getRelatedObjectTitleList.xml (original)
+++ erp5/trunk/bt5/erp5_dms/SkinTemplateItem/portal_skins/erp5_dms/Base_getRelatedObjectTitleList.xml Wed Nov 15 12:11:10 2006
@@ -68,10 +68,17 @@
</item>
<item>
<key> <string>_body</string> </key>
- <value> <string>cat_value=context.getPropertyList(category)\n
-res=context.portal_catalog(relative_url=cat_value)\n
-count=len(res)\n
-return [r.getTitle() for r in res]\n
+ <value> <string># get related object title list in a security-aware way (without throwing exception\n
+# if I don\'t have permissions to access the object)\n
+\n
+cat_value_list=context.getPropertyList(category)\n
+\n
+def getTitleIfAvailable(cat_value):\n
+ ob=context.restrictedTraverse(cat_value,None)\n
+ return ob is not None and ob.getTitle() or \'\'\n
+\n
+title_list=[getTitleIfAvailable(c) for c in cat_value_list]\n
+return [t for t in title_list if t!=\'\']\n
</string> </value>
</item>
<item>
@@ -123,14 +130,14 @@
<string>category</string>
<string>_getattr_</string>
<string>context</string>
- <string>cat_value</string>
- <string>res</string>
- <string>len</string>
- <string>count</string>
+ <string>cat_value_list</string>
+ <string>getTitleIfAvailable</string>
<string>append</string>
<string>$append0</string>
<string>_getiter_</string>
- <string>r</string>
+ <string>c</string>
+ <string>title_list</string>
+ <string>t</string>
</tuple>
</value>
</item>
Modified: erp5/trunk/bt5/erp5_dms/bt/revision
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_dms/bt/revision?rev=11305&r1=11304&r2=11305&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_dms/bt/revision (original)
+++ erp5/trunk/bt5/erp5_dms/bt/revision Wed Nov 15 12:11:10 2006
@@ -1,1 +1,1 @@
-335
+337
More information about the Erp5-report
mailing list