Commit 6301f5f4 authored by Jérome Perrin's avatar Jérome Perrin

Initial checkin. This is a style for distributed reports, using active processes from CMFActivity

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17530 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent affabd27
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="Folder" module="OFS.Folder"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>business_template_registered_skin_selections</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>tokens</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>business_template_registered_skin_selections</string> </key>
<value>
<tuple>
<string>Deferred</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>erp5_deferred_style</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</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_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_text</string> </key>
<value> <string encoding="cdata"><![CDATA[
<tal:block tal:attributes="dummy python:here.Base_activateReport(report_method=report_method, form=form)"/>
]]></string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>report_view</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="Folder" module="OFS.Folder"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>erp5_deferred_style_core</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </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>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</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>request = container.REQUEST\n
RESPONSE = request.RESPONSE\n
\n
portal = context.getPortalObject()\n
N_ = portal.Base_translateString\n
active_process = portal.portal_activities.newActiveProcess()\n
email_to = \'jerome@nexedi.com\' # XXX \n
\n
skin_name = \'ODT\' # hardcoded for now\n
tag = \'active-report-%s\' % random.randint(0, 1000)\n
\n
# compute list of report section to render\n
report_section_list = report_method()\n
\n
# save request parameters (after calling the report_method which may tweak the\n
# request). XXX we exclude some reserved names in a very ad hoc way\n
request_other = dict()\n
for k, v in request.other.items():\n
if k not in (\'TraversalRequestNameStack\', \'AUTHENTICATED_USER\', \'URL\',\n
\'SERVER_URL\', \'AUTHENTICATION_PATH\', \'USER_PREF_LANGUAGES\', \'PARENTS\',\n
\'PUBLISHED\', \'AcceptLanguage\', \'AcceptCharset\', \'RESPONSE\',\n
\'ACTUAL_URL\'):\n
request_other[k] = v\n
\n
localizer_language = portal.Localizer.get_selected_language()\n
\n
for idx, report_section in enumerate(report_section_list):\n
if report_section.getPath():\n
doc = report_section.getObject(portal)\n
else:\n
doc = context\n
doc.activate(activity=\'SQLQueue\',\n
active_process=active_process,\n
tag=tag,\n
).Base_renderReportSection(skin_name=skin_name,\n
localizer_language=localizer_language,\n
report_section=report_section,\n
report_section_idx=idx,\n
request_other=request_other)\n
\n
portal.portal_simulation.activate(after_tag=tag).Base_report(\n
active_process_url=active_process.getRelativeUrl(),\n
skin_name=skin_name,\n
localizer_language=localizer_language,\n
title=form.getProperty(\'title\'),\n
request_other=request_other,\n
form_path=form.getPhysicalPath(),\n
email_to=email_to,\n
)\n
\n
context.activate(after_tag=tag).getTitle()\n
\n
portal.changeSkin(None)\n
return context.Base_redirect(\'view\', keep_items=dict(\n
portal_status_message=N_("Report Started")))\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>report_method, form, **kw</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>2</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>report_method</string>
<string>form</string>
<string>kw</string>
<string>_getattr_</string>
<string>container</string>
<string>request</string>
<string>RESPONSE</string>
<string>context</string>
<string>portal</string>
<string>N_</string>
<string>active_process</string>
<string>email_to</string>
<string>skin_name</string>
<string>random</string>
<string>tag</string>
<string>report_section_list</string>
<string>dict</string>
<string>request_other</string>
<string>_getiter_</string>
<string>k</string>
<string>v</string>
<string>_write_</string>
<string>localizer_language</string>
<string>enumerate</string>
<string>idx</string>
<string>report_section</string>
<string>doc</string>
<string>None</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_activateReport</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>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</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>context.log(\'report_section %s: %s/%s\' % (\n
report_section_idx, context.getPath(), report_section.getFormId(),))\n
request = container.REQUEST\n
request.other.update(request_other)\n
\n
portal = context.getPortalObject()\n
\n
# emulate Localizer\'s __before_publishing_traverse__\n
request.form[\'LOCALIZER_LANGUAGE\'] = localizer_language\n
request.get(\'PARENTS\', []).insert(0, portal)\n
portal.Localizer(context, request)\n
\n
portal.portal_skins.changeSkin(skin_name)\n
\n
# for unicode encoding\n
request.RESPONSE.setHeader("Content-Type", "application/xml; charset=utf-8")\n
\n
report_section.pushReport(portal)\n
\n
if report_section.getFormId():\n
form = getattr(context, report_section.getFormId())\n
else:\n
form = None\n
data = context.render_report_section.pt_render(\n
extra_context=dict(form=form, report_section=report_section))\n
\n
report_section.popReport(portal)\n
\n
return report_section_idx, data\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>localizer_language, skin_name, report_section, report_section_idx, request_other</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>5</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>localizer_language</string>
<string>skin_name</string>
<string>report_section</string>
<string>report_section_idx</string>
<string>request_other</string>
<string>_getattr_</string>
<string>context</string>
<string>container</string>
<string>request</string>
<string>portal</string>
<string>_write_</string>
<string>getattr</string>
<string>form</string>
<string>None</string>
<string>dict</string>
<string>data</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_renderReportSection</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></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>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</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[
request = container.REQUEST\n
request.other.update(request_other)\n
portal = context.getPortalObject()\n
ap = portal.restrictedTraverse(active_process_url)\n
N_ = portal.Base_translateString\n
\n
# emulate Localizer\'s __before_publishing_traverse__\n
request.form[\'LOCALIZER_LANGUAGE\'] = localizer_language\n
request.get(\'PARENTS\', []).insert(0, portal)\n
portal.Localizer(context, request)\n
# set the selected skin\n
portal.portal_skins.changeSkin(skin_name)\n
\n
report_section_list = [r.getResult() for r in ap.getResultList()]\n
report_section_list.sort(lambda a, b:cmp(a[0], b[0]))\n
\n
report_data = context.report_view.pt_render(\n
extra_context=dict(options=dict(),\n
rendered_report_item_list=[r[1] for r in report_section_list],\n
form=portal.restrictedTraverse(form_path)))\n
\n
email_from = portal.getProperty(\'email_from_address\')\n
if portal.getProperty(\'email_from_name\'):\n
email_from = \'"%s" <%s>\' % (portal.getProperty(\'email_from_name\'), email_from)\n
\n
if 0: # send an email ?\n
portal.MailHost.send(\'\'\'From:%(mfrom)s\n
To:%(mto)s\n
Subject:%(subject)s\n
Content-Type: Multipart/Mixed;\n
boundary="Boundary-00=_GJWGGr2lsPnqbw0"\n
\n
--Boundary-00=_GJWGGr2lsPnqbw0\n
Content-Type: text/plain;\n
charset="utf-8"\n
Content-Transfer-Encoding: 7bit\n
Content-Disposition: inline\n
\n
Your report is attached.\n
\n
Maybe here we could sum up the parameters, date, user etc ?\n
\n
--Boundary-00=_GJWGGr2lsPnqbw0\n
Content-Type: application/pdf;\n
name="CasParticuliers.pdf"\n
Content-Transfer-Encoding: 8bit\n
Content-Disposition: attachment;\n
\tfilename="%(subject)s.pdf"\n
\n
%(report_data)s\n
\'\'\' % dict(subject=title,\n
mfrom=email_from,\n
mto=email_to,\n
report_data=report_data))\n
\n
# TODO: this should use portal_contributions\n
doc = portal.document_module.newContent(portal_type=\'File\',\n
title=N_(title),\n
language=localizer_language,\n
data=report_data)\n
\n
content_type = request.RESPONSE.getHeader(\'Content-Type\')\n
if content_type:\n
doc.setContentType(content_type.split(\';\')[0])\n
]]></string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>active_process_url, skin_name, localizer_language, title, request_other, form_path, email_to</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>7</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>active_process_url</string>
<string>skin_name</string>
<string>localizer_language</string>
<string>title</string>
<string>request_other</string>
<string>form_path</string>
<string>email_to</string>
<string>_getattr_</string>
<string>container</string>
<string>request</string>
<string>context</string>
<string>portal</string>
<string>ap</string>
<string>N_</string>
<string>_write_</string>
<string>append</string>
<string>$append0</string>
<string>_getiter_</string>
<string>r</string>
<string>report_section_list</string>
<string>dict</string>
<string>_getitem_</string>
<string>report_data</string>
<string>email_from</string>
<string>doc</string>
<string>content_type</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_report</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></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="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</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_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_text</string> </key>
<value> <string encoding="cdata"><![CDATA[
<tal:block xmlns:tal=\'http://xml.zope.org/namespaces/tal\'\n
xmlns:metal=\'http://xml.zope.org/namespaces/metal\'\n
tal:attributes=\'dummy python:request.RESPONSE.setHeader("Content-Type", "text/html;; charset=utf-8")\'>\n
<!-- The user of this must put a report section named "report_section" in TALES context -->\n
<tal:block tal:define="report_item report_section"> <!-- compatibilty alias -->\n
<tal:block metal:use-macro="here/report_view/macros/render_report_section"/>\n
</tal:block>\n
</tal:block>
]]></string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/xml</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>render_report_section</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
It registers a new skin selection "Deferred" that will use, by default, erp5_odt_style to do the real rendering (for now hardcoded inBase_activateReport) .
It can easily use any style that have the "render_report_section" macro in report_view and understand "rendered_report_item_list" in extra context.
\ No newline at end of file
Copyright (c) 2007 Nexedi SA
\ No newline at end of file
erp5_odt_style > 0.1
\ No newline at end of file
This style use activities and active process to split a report in multiple activities, so that report calculation can be distributed.
\ No newline at end of file
GPL
\ No newline at end of file
jerome
\ No newline at end of file
None
\ No newline at end of file
17
\ No newline at end of file
None
\ No newline at end of file
1
\ No newline at end of file
erp5_deferred_style
erp5_deferred_style_core
\ No newline at end of file
0
\ No newline at end of file
0
\ No newline at end of file
erp5_deferred_style
\ No newline at end of file
0.0.1
\ 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