Commit 8f816ddd authored by Bartek Górny's avatar Bartek Górny

Changed use of caching - the previous version was really dumb...

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10666 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f018c5d8
......@@ -70,30 +70,34 @@
<key> <string>_body</string> </key>
<value> <string>from Products.ERP5Type.Cache import CachingMethod\n
\n
def cached_DMSBaseCategoryHash(item_list,value_list,default_sub_field_property_dict,is_right_display):\n
if default_sub_field_property_dict is None:\n
default_sub_field_property_dict={\'field_type\': \'MultiListField\', \'item_list\': [], \'required\': 0, \'value\': [], \'is_right_display\': 0, \'key\': \'default\', \'title\': \'Categories\', \'size\': 5}\n
def cached_DMSGetItemList(base_category):\n
basecatobject=context.portal_categories.resolveCategory(base_category)\n
return [(context.Base_trimPathName(x,100),y) for x,y in basecatobject.getCategoryChildLogicalPathItemList()]\n
\n
sub_field_dict={}\n
maximum_list_size=5\n
cached_DMSGetItemList=CachingMethod(cached_DMSGetItemList,id=\'DMGetItemListCachedMethodWhatever\')\n
\n
default_sub_field_property_dict[\'field_type\']=\'ListField\'\n
default_sub_field_property_dict[\'size\']=1\n
if default_sub_field_property_dict is None:\n
default_sub_field_property_dict={\'field_type\': \'MultiListField\', \'item_list\': [], \'required\': 0, \'value\': [], \'is_right_display\': 0, \'key\': \'default\', \'title\': \'Categories\', \'size\': 5}\n
\n
for base_category in item_list:\n
if not sub_field_dict.has_key(base_category):\n
basecatobject=context.portal_categories.resolveCategory(base_category)\n
sub_field_property_dict=default_sub_field_property_dict.copy()\n
sub_field_property_dict[\'key\']=base_category\n
sub_field_property_dict[\'title\']=basecatobject.getTranslatedTitle()\n
sub_field_property_dict[\'item_list\']=[(context.Base_trimPathName(x,100),y) for x,y in basecatobject.getCategoryChildLogicalPathItemList()]\n
sub_field_property_dict[\'value\']=context.aq_parent.aq_parent.getProperty(base_category)\n
\n
sub_field_dict[base_category]=sub_field_property_dict\n
sub_field_dict={}\n
maximum_list_size=5\n
\n
return sub_field_dict.values()\n
cached_DMSBaseCategoryHash=CachingMethod(cached_DMSBaseCategoryHash,id=\'DMSParallelListField_DMSBaseCategoryHash\')\n
return cached_DMSBaseCategoryHash(item_list,value_list,default_sub_field_property_dict,is_right_display)\n
default_sub_field_property_dict[\'field_type\']=\'ListField\'\n
default_sub_field_property_dict[\'size\']=1\n
\n
for base_category in item_list:\n
if not sub_field_dict.has_key(base_category):\n
basecatobject=context.portal_categories.resolveCategory(base_category)\n
sub_field_property_dict=default_sub_field_property_dict.copy()\n
sub_field_property_dict[\'key\']=base_category\n
sub_field_property_dict[\'title\']=basecatobject.getTranslatedTitle()\n
# we cache this, so that we can apply expensive path processing techniques\n
sub_field_property_dict[\'item_list\']=cached_DMSGetItemList(base_category)\n
sub_field_property_dict[\'value\']=context.aq_parent.aq_parent.getProperty(base_category)\n
\n
sub_field_dict[base_category]=sub_field_property_dict\n
\n
return sub_field_dict.values()\n
\n
\n
# vim: syntax=python shiftwidth=2\n
......@@ -145,7 +149,17 @@ return cached_DMSBaseCategoryHash(item_list,value_list,default_sub_field_propert
<string>is_right_display</string>
<string>Products.ERP5Type.Cache</string>
<string>CachingMethod</string>
<string>cached_DMSBaseCategoryHash</string>
<string>cached_DMSGetItemList</string>
<string>None</string>
<string>sub_field_dict</string>
<string>maximum_list_size</string>
<string>_write_</string>
<string>_getiter_</string>
<string>base_category</string>
<string>_getattr_</string>
<string>context</string>
<string>basecatobject</string>
<string>sub_field_property_dict</string>
</tuple>
</value>
</item>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment