[Erp5-report] r28743 - in /erp5/trunk/bt5/erp5_commerce: SkinTemplateItem/portal_skins/erp5...
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Sep 2 08:24:27 CEST 2009
Author: lucas
Date: Wed Sep 2 08:24:26 2009
New Revision: 28743
URL: http://svn.erp5.org?rev=28743&view=rev
Log:
- does not matter which is the context, all the products must be shown randomly.
Added:
erp5/trunk/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce_widget_library/WebSite_getProductList.xml
Modified:
erp5/trunk/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce_widget_library/WebSection_viewSelectedProductWidget.xml
erp5/trunk/bt5/erp5_commerce/bt/revision
Modified: erp5/trunk/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce_widget_library/WebSection_viewSelectedProductWidget.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce_widget_library/WebSection_viewSelectedProductWidget.xml?rev=28743&r1=28742&r2=28743&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce_widget_library/WebSection_viewSelectedProductWidget.xml [utf8] (original)
+++ erp5/trunk/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce_widget_library/WebSection_viewSelectedProductWidget.xml [utf8] Wed Sep 2 08:24:26 2009
@@ -54,13 +54,15 @@
- make it hierarchic\n
-->\n
</tal:block>\n
-<div tal:define="site_url python:here.getWebSiteValue().absolute_url();\n
+<div tal:define="web_site python: here.getWebSiteValue();\n
+ site_url python: web_site.absolute_url();\n
current_web_section python:request.get(\'current_web_section\', here);\n
shopping_cart here/SaleOrder_getShoppingCart;\n
- currency_symbol python: shopping_cart.SaleOrder_getShoppingCartDefaultCurrencySymbol();"\n
+ currency_symbol python: shopping_cart.SaleOrder_getShoppingCartDefaultCurrencySymbol();\n
+ product_list python: web_site.WebSite_getProductList(limit=5);"\n
i18n:translate="" i18n:domain="ui" i18n:attributes="title"\n
title="Sections accessible from here." class="selected-product">\n
- <tal:block tal:repeat="product python: here.WebSection_getProductList(limit=5)">\n
+ <tal:block tal:repeat="product python: product_list">\n
<div tal:define="product_href python: \'%s/product_module/%s/%s\' % (site_url, product.getId(), \'Resource_viewAsShop\');\n
price python: here.WebSection_unrestrictedGetPrice(product)">\n
<a href="#" tal:attributes="href product_href">\n
Added: erp5/trunk/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce_widget_library/WebSite_getProductList.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce_widget_library/WebSite_getProductList.xml?rev=28743&view=auto
==============================================================================
--- erp5/trunk/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce_widget_library/WebSite_getProductList.xml (added)
+++ erp5/trunk/bt5/erp5_commerce/SkinTemplateItem/portal_skins/erp5_commerce_widget_library/WebSite_getProductList.xml [utf8] Wed Sep 2 08:24:26 2009
@@ -1,0 +1,192 @@
+<?xml version="1.0"?>
+<ZopeData>
+ <record id="1" aka="AAAAAAAAAAE=">
+ <pickle>
+ <tuple>
+ <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
+ <tuple/>
+ </tuple>
+ </pickle>
+ <pickle>
+ <dictionary>
+ <item>
+ <key> <string>Script_magic</string> </key>
+ <value> <int>3</int> </value>
+ </item>
+ <item>
+ <key> <string>_bind_names</string> </key>
+ <value>
+ <object>
+ <klass>
+ <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
+ </klass>
+ <tuple/>
+ <state>
+ <dictionary>
+ <item>
+ <key> <string>_asgns</string> </key>
+ <value>
+ <dictionary>
+ <item>
+ <key> <string>name_container</string> </key>
+ <value> <string>container</string> </value>
+ </item>
+ <item>
+ <key> <string>name_context</string> </key>
+ <value> <string>context</string> </value>
+ </item>
+ <item>
+ <key> <string>name_m_self</string> </key>
+ <value> <string>script</string> </value>
+ </item>
+ <item>
+ <key> <string>name_subpath</string> </key>
+ <value> <string>traverse_subpath</string> </value>
+ </item>
+ </dictionary>
+ </value>
+ </item>
+ </dictionary>
+ </state>
+ </object>
+ </value>
+ </item>
+ <item>
+ <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 randrange\n
+\n
+web_site = context.getWebSiteValue() or context.REQUEST.get(\'current_web_site\')\n
+product_list = []\n
+kw[\'portal_type\'] = \'Product\'\n
+kw[\'limit\'] = limit\n
+\n
+# Getting all the products from all the visible Web Section.\n
+web_section_list = web_site.WebSite_getMainSectionList()\n
+for web_section in web_section_list:\n
+ product_result_list = web_section.WebSection_getDocumentValueListBase(all_versions=1, all_languages=1, **kw)\n
+ for product in product_result_list:\n
+ if product.getObject() not in product_list:\n
+ product_list.append(product.getObject())\n
+\n
+if len(product_list) <= limit:\n
+ product_list = [x for x in product_list if x.getPortalType() == \'Product\']\n
+else:\n
+ random_index_list = []\n
+ while len(random_index_list) < limit:\n
+ random_number = randrange(0, len(product_list))\n
+ if random_number not in random_index_list:\n
+ random_index_list.append(random_number)\n
+ product_list = [product_list[x] for x in random_index_list if product_list[x].getPortalType() == \'Product\']\n
+return product_list\n
+
+
+]]></string> </value>
+ </item>
+ <item>
+ <key> <string>_code</string> </key>
+ <value>
+ <none/>
+ </value>
+ </item>
+ <item>
+ <key> <string>_params</string> </key>
+ <value> <string>limit=5, **kw</string> </value>
+ </item>
+ <item>
+ <key> <string>_proxy_roles</string> </key>
+ <value>
+ <tuple>
+ <string>Assignee</string>
+ <string>Assignor</string>
+ <string>Associate</string>
+ <string>Auditor</string>
+ <string>Authenticated</string>
+ <string>Author</string>
+ <string>Manager</string>
+ <string>Member</string>
+ <string>Owner</string>
+ <string>Reviewer</string>
+ </tuple>
+ </value>
+ </item>
+ <item>
+ <key> <string>errors</string> </key>
+ <value>
+ <tuple/>
+ </value>
+ </item>
+ <item>
+ <key> <string>func_code</string> </key>
+ <value>
+ <object>
+ <klass>
+ <global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
+ </klass>
+ <tuple/>
+ <state>
+ <dictionary>
+ <item>
+ <key> <string>co_argcount</string> </key>
+ <value> <int>1</int> </value>
+ </item>
+ <item>
+ <key> <string>co_varnames</string> </key>
+ <value>
+ <tuple>
+ <string>limit</string>
+ <string>kw</string>
+ <string>random</string>
+ <string>randrange</string>
+ <string>_getattr_</string>
+ <string>context</string>
+ <string>web_site</string>
+ <string>product_list</string>
+ <string>_write_</string>
+ <string>web_section_list</string>
+ <string>_getiter_</string>
+ <string>web_section</string>
+ <string>_apply_</string>
+ <string>product_result_list</string>
+ <string>product</string>
+ <string>len</string>
+ <string>append</string>
+ <string>$append0</string>
+ <string>x</string>
+ <string>random_index_list</string>
+ <string>random_number</string>
+ <string>_getitem_</string>
+ </tuple>
+ </value>
+ </item>
+ </dictionary>
+ </state>
+ </object>
+ </value>
+ </item>
+ <item>
+ <key> <string>func_defaults</string> </key>
+ <value>
+ <tuple>
+ <int>5</int>
+ </tuple>
+ </value>
+ </item>
+ <item>
+ <key> <string>id</string> </key>
+ <value> <string>WebSite_getProductList</string> </value>
+ </item>
+ <item>
+ <key> <string>warnings</string> </key>
+ <value>
+ <tuple/>
+ </value>
+ </item>
+ </dictionary>
+ </pickle>
+ </record>
+</ZopeData>
Modified: erp5/trunk/bt5/erp5_commerce/bt/revision
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_commerce/bt/revision?rev=28743&r1=28742&r2=28743&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_commerce/bt/revision [utf8] (original)
+++ erp5/trunk/bt5/erp5_commerce/bt/revision [utf8] Wed Sep 2 08:24:26 2009
@@ -1,1 +1,1 @@
-180
+182
More information about the Erp5-report
mailing list