Commit af25a850 authored by Nicolas Delaby's avatar Nicolas Delaby

avoid acquisition lookups:

* Get tools from portal
* Call getPortalXXXTypeList from portal itself

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@39984 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 68ec0569
...@@ -2,10 +2,7 @@ ...@@ -2,10 +2,7 @@
<ZopeData> <ZopeData>
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/> <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
...@@ -54,16 +51,16 @@ ...@@ -54,16 +51,16 @@
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>from Products.ERP5Type.Cache import CachingMethod\n <value> <string>from Products.ERP5Type.Cache import CachingMethod\n
portal = context.getPortalObject()\n
\n \n
\n if context.getPortalType() in portal.getPortalSaleTypeList():\n
if context.getPortalType() in context.getPortalSaleTypeList():\n
use_list = context.portal_preferences.getPreferredSaleUseList()\n use_list = context.portal_preferences.getPreferredSaleUseList()\n
elif context.getPortalType() in context.getPortalPurchaseTypeList():\n elif context.getPortalType() in portal.getPortalPurchaseTypeList():\n
use_list = context.portal_preferences.getPreferredPurchaseUseList()\n use_list = portal.portal_preferences.getPreferredPurchaseUseList()\n
else:\n else:\n
use_list = context.portal_preferences.getPreferredPurchaseUseList() + context.portal_preferences.getPreferredSaleUseList()\n use_list = portal.portal_preferences.getPreferredPurchaseUseList() + portal.portal_preferences.getPreferredSaleUseList()\n
\n \n
if len(use_list) == 0:\n if not use_list:\n
return []\n return []\n
\n \n
sql_kw = {}\n sql_kw = {}\n
...@@ -162,14 +159,15 @@ return getResourceItemList(sql_kw)\n ...@@ -162,14 +159,15 @@ return getResourceItemList(sql_kw)\n
<string>CachingMethod</string> <string>CachingMethod</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>portal</string>
<string>use_list</string> <string>use_list</string>
<string>len</string>
<string>sql_kw</string> <string>sql_kw</string>
<string>resource_title</string> <string>resource_title</string>
<string>AttributeError</string> <string>AttributeError</string>
<string>None</string> <string>None</string>
<string>reference</string> <string>reference</string>
<string>_write_</string> <string>_write_</string>
<string>len</string>
<string>getResourceItemList</string> <string>getResourceItemList</string>
<string>append</string> <string>append</string>
<string>$append0</string> <string>$append0</string>
......
...@@ -2,10 +2,7 @@ ...@@ -2,10 +2,7 @@
<ZopeData> <ZopeData>
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/> <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
...@@ -60,28 +57,29 @@ ...@@ -60,28 +57,29 @@
"""\n """\n
from Products.ERP5Type.Message import translateString\n from Products.ERP5Type.Message import translateString\n
from Products.ERP5Type.Log import log\n from Products.ERP5Type.Log import log\n
portal = context.getPortalObject()\n
\n \n
# Retrieve line and cell portal type\n # Retrieve line and cell portal type\n
line_portal_type_list = [x for x in context.getTypeInfo().getTypeAllowedContentTypeList() \\\n line_portal_type_list = [x for x in context.getTypeInfo().getTypeAllowedContentTypeList() \\\n
if x in context.getPortalMovementTypeList()]\n if x in portal.getPortalMovementTypeList()]\n
line_portal_type = line_portal_type_list[0]\n line_portal_type = line_portal_type_list[0]\n
cell_portal_type_list = [x for x in context.portal_types[line_portal_type].getTypeAllowedContentTypeList() \\\n cell_portal_type_list = [x for x in portal.portal_types[line_portal_type].getTypeAllowedContentTypeList() \\\n
if x in context.getPortalMovementTypeList()]\n if x in portal.getPortalMovementTypeList()]\n
cell_portal_type = cell_portal_type_list[0]\n cell_portal_type = cell_portal_type_list[0]\n
\n \n
per_resource_line_dict = {}\n per_resource_line_dict = {}\n
\n \n
for line in listbox:\n for line in listbox:\n
# Only create line if user has selected a resource\n # Only create line if user has selected a resource\n
if line.has_key(\'listbox_key\') and (line.get(\'resource_relative_url\', None) not in ("", None) \\\n if \'listbox_key\' in line and (line.get(\'resource_relative_url\', None) not in ("", None) \\\n
or line.get(\'source\', None) not in ("", None)):\n or line.get(\'source\', None) not in ("", None)):\n
line_id = line[\'listbox_key\']\n line_id = line[\'listbox_key\']\n
\n \n
if line.get(\'resource_relative_url\', None) not in ("", None):\n if line.get(\'resource_relative_url\', None) not in ("", None):\n
product = context.getPortalObject().restrictedTraverse(line["resource_relative_url"])\n product = portal.restrictedTraverse(line["resource_relative_url"])\n
\n \n
if line.get(\'source\', None) not in ("", None):\n if line.get(\'source\', None) not in ("", None):\n
source_document = context.getPortalObject().restrictedTraverse(line[\'source\'])\n source_document = portal.restrictedTraverse(line[\'source\'])\n
product = source_document.getResourceValue()\n product = source_document.getResourceValue()\n
else:\n else:\n
source_document = None\n source_document = None\n
...@@ -94,7 +92,7 @@ for line in listbox:\n ...@@ -94,7 +92,7 @@ for line in listbox:\n
# if there was no document line already defined\n # if there was no document line already defined\n
# for the document, add a new document line\n # for the document, add a new document line\n
\n \n
# We check if havn\'t already create a line for the same resource\n # We check if haven\'t already create a line for the same resource\n
key = "%s" %(product.getRelativeUrl(),)\n key = "%s" %(product.getRelativeUrl(),)\n
trade_document_line = per_resource_line_dict.get(key, None)\n trade_document_line = per_resource_line_dict.get(key, None)\n
if trade_document_line is None:\n if trade_document_line is None:\n
...@@ -169,11 +167,12 @@ return context.Base_redirect(kw[\'form_id\'], keep_items=dict(\n ...@@ -169,11 +167,12 @@ return context.Base_redirect(kw[\'form_id\'], keep_items=dict(\n
<string>translateString</string> <string>translateString</string>
<string>Products.ERP5Type.Log</string> <string>Products.ERP5Type.Log</string>
<string>log</string> <string>log</string>
<string>_getattr_</string>
<string>context</string>
<string>portal</string>
<string>append</string> <string>append</string>
<string>$append0</string> <string>$append0</string>
<string>_getiter_</string> <string>_getiter_</string>
<string>_getattr_</string>
<string>context</string>
<string>x</string> <string>x</string>
<string>line_portal_type_list</string> <string>line_portal_type_list</string>
<string>_getitem_</string> <string>_getitem_</string>
......
1014 1015
\ No newline at end of file \ 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