Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5_fork
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Eteri
erp5_fork
Commits
2d8fdf65
Commit
2d8fdf65
authored
Jan 24, 2013
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Cache WebSite/WebSection_getProductList"
This reverts commit
339cb7c6
.
parent
10f984c8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
42 deletions
+34
-42
bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce_widget_library/WebSection_getProductList.xml
...rp5_commerce_widget_library/WebSection_getProductList.xml
+12
-23
bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce_widget_library/WebSite_getProductList.xml
...s/erp5_commerce_widget_library/WebSite_getProductList.xml
+21
-18
bt5/erp5_commerce/bt/revision
bt5/erp5_commerce/bt/revision
+1
-1
No files found.
bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce_widget_library/WebSection_getProductList.xml
View file @
2d8fdf65
...
...
@@ -50,39 +50,28 @@
</item>
<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
<value>
<string>
#
TODO : USE CACHE
\n
#the goal of this script is to get all the related product of this section
\n
current_web_section = context.REQUEST.get(\'current_web_section\', context)\n
product_list = []\n
\n
if not kw.has_key(\'portal_type\'):\n
kw[\'portal_type\'] = \'Product\'\n
\t \n
if not kw.has_key(\'limit\'):\t \n
kw[\'limit\'] = limit\n
\t\t \n
if not kw.has_key(\'all_versions\'):\t \n
kw[\'all_versions\'] = 1\n
if not kw.has_key(\'limit\'):\t\t \n
kw[\'limit\'] = limit\t\t \n
\t\t \n
if not kw.has_key(\'all_versions\'):\t\t \n
kw[\'all_versions\'] = 1\t\t \n
\t\t \n
if not kw.has_key(\'all_languages\'):\t\t \n
kw[\'all_languages\'] = 1\n
kw[\'all_languages\'] = 1\
t\t \
n
\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
kw[key] = int(kw[key])\t\t \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
product_list = current_web_section.getDocumentValueList(**kw)\n
return product_list\n
</string>
</value>
</item>
<item>
...
...
bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce_widget_library/WebSite_getProductList.xml
View file @
2d8fdf65
...
...
@@ -52,31 +52,34 @@
<key>
<string>
_body
</string>
</key>
<value>
<string
encoding=
"cdata"
>
<![CDATA[
#TODO : USE CACHE\n
# 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 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
if not kw.has_key(\'portal_type\'):\t \t \n
kw[\'portal_type\'] = \'Product\'\n
\n
if len(product_dict) >
limit:\n
return random.sample(product_dict.values(), limit)\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
return product_dict.values()\n
if len(product_dict) >
limit:\n
random_uid_list = []\n
key_list = product_dict.keys()\n
while len(random_uid_list)
< limit:
\n
random_uid =
choice(key_list)\n
key_list.remove(random_uid)\n
random_uid_list.append(random_uid)\n
product_list =
[product_dict.get(uid)
for
uid
in
random_uid_list]\n
else:\n
product_list =
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_list\n
]]
></string>
</value>
...
...
bt5/erp5_commerce/bt/revision
View file @
2d8fdf65
28
5
28
4
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment