Commit 7ad0751c authored by Rafael Monnerat's avatar Rafael Monnerat Committed by Xiaowu Zhang

Revert usage of Caching Methods

parent c1a6fc48
......@@ -10,6 +10,12 @@
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
......@@ -51,9 +57,13 @@
<item>
<key> <string>_body</string> </key>
<value> <string># the goal of this script is to get all the related product of this section\n
from Products.ERP5Type.Cache import CachingMethod\n
\n
current_web_section = context.REQUEST.get(\'current_web_section\', context)\n
\n
# XXX Somehow Customize it Only list published products.\n
kw[\'validation_state\'] = \'published\'\n
\n
\n
if not kw.has_key(\'portal_type\'):\n
kw[\'portal_type\'] = \'Product\'\n
\t \n
......@@ -69,20 +79,13 @@ if not kw.has_key(\'all_languages\'):\t\t \n
for key in [\'limit\',\'all_versions\',\'all_languages\']:\t\t \n
kw[key] = int(kw[key])\n
\n
\n
def getProductList(context_relative_url, limit, all_versions, all_languages):\n
# Gabriel: The condition was added to not break the paypal return\n
# after finish the payment. The verify_sign is checked because all\n
# data from paypal have this key\n
if kw.has_key(\'quantity\') and kw.has_key("verify_sign"):\n
del kw[\'quantity\']\n
# Gabriel: The condition was added to not break the paypal return\n
# after finish the payment. The verify_sign is checked because all\n
# data from paypal have this key\n
if kw.has_key(\'quantity\') and kw.has_key("verify_sign"):\n
del kw[\'quantity\']\n
\t\t \n
return current_web_section.getDocumentValueList(**kw)\n
\n
\n
return CachingMethod(getProductList,\n
id="WebSection_getProductList_ecommerce",\n
cache_factory=\'erp5_ui_short\')(current_web_section.getRelativeUrl(),kw[\'limit\'],kw[\'all_versions\'], kw[\'all_languages\'])\n
return current_web_section.getDocumentValueList(**kw)\n
</string> </value>
</item>
<item>
......
......@@ -54,30 +54,23 @@
# The goal of this script is to get all the products from all the visible Web Sections\n
# and it must select randomly which product must be displayed for a given context.\n
from Products.ERP5Type.Cache import CachingMethod\n
from random import choice\n
\n
if not kw.has_key(\'portal_type\'):\n
kw[\'portal_type\'] = \'Product\'\n
\n
def getProductList(limit, portal_type):\n
from random import choice\n
\n
web_site = context.getWebSiteValue() or context.REQUEST.get(\'current_web_site\')\n
web_site = context.getWebSiteValue() or context.REQUEST.get(\'current_web_site\')\n
\n
# Getting all the products from all the visible Web Section.\n
product_dict = {}\n
for web_section in web_site.WebSite_getMainSectionList():\n
for product in web_section.getDocumentValueList(all_versions=1, all_languages=1, **kw):\n
product_dict[product.uid] = product\n
# Getting all the products from all the visible Web Section.\n
product_dict = {}\n
for web_section in web_site.WebSite_getMainSectionList():\n
for product in web_section.getDocumentValueList(all_versions=1, all_languages=1, **kw):\n
product_dict[product.uid] = product\n
\n
if len(product_dict) > limit:\n
return random.sample(product_dict.values(), limit)\n
if len(product_dict) > limit:\n
return random.sample(product_dict.values(), limit)\n
\n
return product_dict.values()\n
\n
return CachingMethod(getProductList,\n
id="WebSite_getProductList_ecommerce",\n
cache_factory=\'erp5_ui_short\')(limit, kw[\'portal_type\'])\n
return product_dict.values()\n
]]></string> </value>
......
322
\ No newline at end of file
323
\ No newline at end of file
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