Commit cad87037 authored by Nicolas Delaby's avatar Nicolas Delaby

enable deferred listbox rendering for list report_mode

parent fd724f79
......@@ -108,7 +108,18 @@ if hasattr(form, \'ZScriptHTML_tryParams\'):\n
else:\n
params[\'format\'] = format\n
\n
activity_context.activate(\n
if \'form_id\' in params:\n
list_form = getattr(context, params[\'form_id\'], None)\n
else:\n
list_form = form\n
if params.get(\'print_mode\') == \'list\' and getattr(list_form, \'listbox\', None) is not None: # XXX harcoded id\n
# If a listbox is present in form, use deferred renderer\n
tag = list_form.listbox.initDeferredRendering(user_name=user_name,\n
skin_name=skin_name,\n
format=format,\n
**params)\n
else:\n
activity_context.activate(\n
activity=\'SQLQueue\', tag=tag, priority=priority).Base_renderSimpleView(\n
localizer_language=localizer_language,\n
skin_name=skin_name,\n
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</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>portal = context.getPortalObject()\n
active_process = portal.restrictedTraverse(active_process_path)\n
listbox = portal.restrictedTraverse(listbox_path)\n
portal.changeSkin(skin_name)\n
request = container.REQUEST\n
request.set(\'portal_skin\', skin_name)\n
\n
parameter_dict = dict(active_process_path=active_process_path)\n
if format:\n
parameter_dict[\'format\'] = format\n
report_data = listbox.aq_parent(**parameter_dict) # call the form\n
context.getPortalObject().portal_skins.changeSkin(None)\n
request.set(\'portal_skin\', None)\n
\n
attachment_name_list = [x[len(\' filename=\'):] for x in (request.RESPONSE.getHeader(\n
\'content-disposition\') or \'\').split(\';\')\n
if x.startswith(\' filename=\')]\n
if attachment_name_list:\n
attachment_name = attachment_name_list[0]\n
else:\n
attachment_name = context.getTranslatedTitle()\n
if attachment_name.startswith(\'"\'):\n
attachment_name = attachment_name[1:]\n
if attachment_name.endswith(\'"\'):\n
attachment_name = attachment_name[:-1]\n
\n
attachment_list = (\n
{\'mime_type\': (request.RESPONSE.getHeader(\'content-type\') or \'application/octet-stream;\').split(\';\')[0],\n
\'content\': \'%s\' % report_data,\n
\'name\': attachment_name},)\n
\n
return getattr(context, transport_method_id)(attachment_list, user_name)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>listbox_path, active_process_path, skin_name, transport_method_id, user_name, format</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_finaliseDeferredListBox</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -73,16 +73,7 @@ attachment_list = (\n
\'content\': \'%s\' % report_data,\n
\'name\': attachment_name},)\n
\n
# XXX Use notification message to improve message content\n
portal.portal_notifications.sendMessage(\n
recipient=user_name,\n
subject=attachment_name.rsplit(\'.\', 1)[0],\n
message=str(translateString(\'Your report is attached.\\n\')),\n
message_text_format=\'text/plain\',\n
notifier_list=(\'Mail Message\',),\n
store_as_event=False,\n
attachment_list=attachment_list,\n
)\n
return context.Base_sendReportByEmail(attachment_list, user_name)\n
</string> </value>
</item>
<item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</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>from Products.ERP5Type.Message import translateString\n
portal = context.getPortalObject()\n
request = portal.REQUEST\n
\n
if not attachment_list:\n
raise ValueError\n
attachment_name = attachment_list[0][\'name\']\n
\n
portal.portal_notifications.sendMessage(\n
recipient=user_name,\n
subject=attachment_name.rsplit(\'.\', 1)[0],\n
message=str(translateString(\'Your report is attached.\\n\')),\n
message_text_format=\'text/plain\',\n
notifier_list=(\'Mail Message\',),\n
store_as_event=False,\n
attachment_list=attachment_list,\n
)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>attachment_list, user_name</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_sendReportByEmail</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</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>portal = context.getPortalObject()\n
REQUEST = portal.REQUEST\n
selection = portal.portal_selections.getSelectionFor(selection_name)\n
listbox = portal.restrictedTraverse(listbox_path)\n
\n
REQUEST[\'PARENTS\'][0] = context\n
REQUEST.set(\'here\', context)\n
parameter_dict = selection.getParams()\n
list_start = parameter_dict.get(\'list_start\', 0)\n
\n
renderer = listbox.get_value(\'default\', render_format=\'deferred_list\')\n
renderer.setSelectionName(selection_name)\n
line_list = renderer.call_render(*renderer.positinal_argument_list, **renderer.named_argument_list)\n
if list_start != 0:\n
# remove header column for all pages except first one\n
line_list = line_list[1:]\n
total_pages = renderer.total_pages\n
current_page = renderer.current_page + 1\n
if total_pages != current_page:\n
portal.portal_selections.nextPage(selection_name, [], list_start=list_start)\n
context.activate(active_process=active_process_path,\n
activity=\'SQLQueue\',\n
tag=selection_name).Base_storeListBoxPage(listbox_path,\n
selection_name,\n
active_process_path,\n
skin_name,\n
user_name,\n
format)\n
else:\n
context.activate(after_tag=selection_name).Base_finaliseDeferredListBox(listbox_path,\n
active_process_path,\n
skin_name,\n
\'Base_sendReportByEmail\',\n
user_name, format)\n
return line_list\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>listbox_path, selection_name, active_process_path, skin_name, user_name, format</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_storeListBoxPage</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
103
\ No newline at end of file
107
\ 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