Commit db181f45 authored by Jérome Perrin's avatar Jérome Perrin

helper scripts to get all entities of a given role, and all resources of a given use

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28348 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent bc72c8a8
<?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>try:\n
return container.REQUEST.other[script.id]\n
except KeyError:\n
pass\n
\n
if not role_list:\n
return []\n
\n
portal = context.getPortalObject()\n
\n
if not portal_type:\n
portal_type = portal.getPortalNodeTypeList()\n
\n
role_uid = [portal.portal_categories.resolveCategory(role).getUid()\n
for role in role_list]\n
\n
result = container.REQUEST.other[script.id] = [(\'\', \'\')] + [\n
(x.getTitle(), x.getRelativeUrl()) for x in \n
context.portal_catalog.searchResults(\n
portal_type=portal_type,\n
default_role_uid=role_uid,\n
validation_state=validation_state,\n
sort_on=((\'portal_type\', \'asc\'),\n
(\'title\', \'asc\'))) ]\n
\n
return result\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>role_list, validation_state=\'validated\', portal_type=None</string> </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>3</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>role_list</string>
<string>validation_state</string>
<string>portal_type</string>
<string>_getitem_</string>
<string>_getattr_</string>
<string>container</string>
<string>script</string>
<string>KeyError</string>
<string>context</string>
<string>portal</string>
<string>append</string>
<string>$append0</string>
<string>_getiter_</string>
<string>role</string>
<string>role_uid</string>
<string>x</string>
<string>result</string>
<string>_write_</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<string>validated</string>
<none/>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getEntityItemList</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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>try:\n
return container.REQUEST.other[script.id]\n
except KeyError:\n
pass\n
\n
if not use_list:\n
return []\n
\n
portal = context.getPortalObject()\n
translateString = portal.Base_translateString\n
\n
if portal_type is None:\n
portal_type = portal.getPortalResourceTypeList()\n
\n
use_uid = [context.portal_categories.resolveCategory(use).getUid()\n
for use in use_list]\n
\n
result = [(\'\', \'\')]\n
\n
for resource in context.portal_catalog.searchResults(\n
portal_type=portal_type,\n
default_use_uid=use_uid,\n
validation_state=validation_state,\n
sort_on=((\'portal_type\', \'asc\'),\n
(\'title\', \'asc\'))) :\n
if resource.getQuantityUnit():\n
result.append(\n
(\'%s (%s)\' % (resource.getTitle(),\n
translateString(resource.getQuantityUnitTitle()),),\n
resource.getRelativeUrl()))\n
else:\n
result.append(\n
(resource.getTitle(),\n
resource.getRelativeUrl()))\n
\n
container.REQUEST.other[script.id] = result\n
\n
return result\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>use_list, validation_state=\'validated\', portal_type=None</string> </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>3</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>use_list</string>
<string>validation_state</string>
<string>portal_type</string>
<string>_getitem_</string>
<string>_getattr_</string>
<string>container</string>
<string>script</string>
<string>KeyError</string>
<string>context</string>
<string>portal</string>
<string>translateString</string>
<string>None</string>
<string>append</string>
<string>$append0</string>
<string>_getiter_</string>
<string>use</string>
<string>use_uid</string>
<string>result</string>
<string>resource</string>
<string>_write_</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<string>validated</string>
<none/>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getResourceItemList</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
714
\ No newline at end of file
715
\ 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