[Erp5-report] r31182 jerome - in /erp5/trunk/bt5/erp5_deferred_style: SkinTemplateItem/port...

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Dec 9 13:16:41 CET 2009


Author: jerome
Date: Wed Dec  9 13:16:39 2009
New Revision: 31182

URL: http://svn.erp5.org?rev=31182&view=rev
Log:
2009-09-12 Jérome
* Allow rendering of any form / printout in deferred mode

Added:
    erp5/trunk/bt5/erp5_deferred_style/SkinTemplateItem/portal_skins/erp5_deferred_style/Base_activateSimpleView.xml
    erp5/trunk/bt5/erp5_deferred_style/SkinTemplateItem/portal_skins/erp5_deferred_style_core/Base_renderSimpleView.xml
Modified:
    erp5/trunk/bt5/erp5_deferred_style/bt/change_log
    erp5/trunk/bt5/erp5_deferred_style/bt/revision

Added: erp5/trunk/bt5/erp5_deferred_style/SkinTemplateItem/portal_skins/erp5_deferred_style/Base_activateSimpleView.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_deferred_style/SkinTemplateItem/portal_skins/erp5_deferred_style/Base_activateSimpleView.xml?rev=31182&view=auto
==============================================================================
--- erp5/trunk/bt5/erp5_deferred_style/SkinTemplateItem/portal_skins/erp5_deferred_style/Base_activateSimpleView.xml (added)
+++ erp5/trunk/bt5/erp5_deferred_style/SkinTemplateItem/portal_skins/erp5_deferred_style/Base_activateSimpleView.xml [utf8] Wed Dec  9 13:16:39 2009
@@ -1,0 +1,223 @@
+<?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>from Products.ERP5Type.Message import translateString\n
+portal = context.getPortalObject()\n
+request = portal.REQUEST\n
+format = request.get(\'format\', \'\')\n
+skin_name = request[\'deferred_portal_skin\']\n
+\n
+tag = \'active-report-wrapped-%s\' % random.randint(0, 1000)\n
+priority = 3 # TODO: site preference\n
+\n
+person_value = portal.ERP5Site_getAuthenticatedMemberPersonValue()\n
+if person_value is None:\n
+  portal.changeSkin(None)\n
+  return context.Base_redirect(\'view\', keep_items=dict(\n
+              portal_status_message=translateString(\n
+                        "No person found for your user")))\n
+\n
+if person_value.getDefaultEmailText(\'\') in (\'\', None):\n
+  portal.changeSkin(None)\n
+  return context.Base_redirect(\'view\', keep_items=dict(\n
+              portal_status_message=translateString(\n
+                        "You haven\'t defined your email address")))\n
+  \n
+user_name = context.portal_membership.getAuthenticatedMember().getUserName()\n
+\n
+# save request parameters\n
+# XXX we exclude some reserved names in a very ad hoc way\n
+request_form = dict()\n
+for k, v in request.form.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
+    # XXX proxy fields stores a cache in request.other that cannot be pickled\n
+    if k.startswith(\'field__proxyfield\'):\n
+      continue\n
+    # Remove FileUpload parameters\n
+    elif getattr(v, \'headers\', \'\'):\n
+      continue\n
+    request_form[k] = v\n
+\n
+localizer_language = portal.Localizer.get_selected_language()\n
+\n
+activity_context = context\n
+if activity_context == portal:\n
+  # portal is not an active object\n
+  activity_context = portal.portal_simulation\n
+\n
+\n
+params = dict()\n
+form = getattr(context, deferred_style_dialog_method)\n
+if hasattr(form, \'ZScriptHTML_tryParams\'):\n
+  # Some actions are wrapped by a script.\n
+  # In that case we look at script signature to pass them the sames\n
+  for param in form.ZScriptHTML_tryParams():\n
+    params[param] = request.get(param)\n
+else:\n
+  params[\'format\'] = format\n
+\n
+activity_context.activate(\n
+    activity=\'SQLQueue\', tag=tag, priority=priority).Base_renderSimpleView(\n
+           localizer_language=localizer_language,\n
+           skin_name=skin_name,\n
+           request_form=request_form,\n
+           deferred_style_dialog_method=deferred_style_dialog_method,\n
+           user_name=user_name,\n
+           params=params,\n
+          )\n
+\n
+context.activate(activity=\'SQLQueue\', after_tag=tag).getTitle()\n
+\n
+portal.changeSkin(None)\n
+return context.Base_redirect(\'view\', keep_items=dict(\n
+              portal_status_message=translateString("Report Started")))\n
+</string> </value>
+        </item>
+        <item>
+            <key> <string>_code</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_params</string> </key>
+            <value> <string>deferred_style_dialog_method, form_id, **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>deferred_style_dialog_method</string>
+                            <string>form_id</string>
+                            <string>kw</string>
+                            <string>Products.ERP5Type.Message</string>
+                            <string>translateString</string>
+                            <string>_getattr_</string>
+                            <string>context</string>
+                            <string>portal</string>
+                            <string>request</string>
+                            <string>format</string>
+                            <string>_getitem_</string>
+                            <string>skin_name</string>
+                            <string>random</string>
+                            <string>tag</string>
+                            <string>priority</string>
+                            <string>person_value</string>
+                            <string>None</string>
+                            <string>dict</string>
+                            <string>user_name</string>
+                            <string>request_form</string>
+                            <string>_getiter_</string>
+                            <string>k</string>
+                            <string>v</string>
+                            <string>getattr</string>
+                            <string>_write_</string>
+                            <string>localizer_language</string>
+                            <string>activity_context</string>
+                            <string>params</string>
+                            <string>form</string>
+                            <string>hasattr</string>
+                            <string>param</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_activateSimpleView</string> </value>
+        </item>
+        <item>
+            <key> <string>warnings</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>

Added: erp5/trunk/bt5/erp5_deferred_style/SkinTemplateItem/portal_skins/erp5_deferred_style_core/Base_renderSimpleView.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_deferred_style/SkinTemplateItem/portal_skins/erp5_deferred_style_core/Base_renderSimpleView.xml?rev=31182&view=auto
==============================================================================
--- erp5/trunk/bt5/erp5_deferred_style/SkinTemplateItem/portal_skins/erp5_deferred_style_core/Base_renderSimpleView.xml (added)
+++ erp5/trunk/bt5/erp5_deferred_style/SkinTemplateItem/portal_skins/erp5_deferred_style_core/Base_renderSimpleView.xml [utf8] Wed Dec  9 13:16:39 2009
@@ -1,0 +1,177 @@
+<?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># Render a "normal" form or an OOo template in an activity and send it by email\n
+from Products.ERP5Type.Message import translateString\n
+portal = context.getPortalObject()\n
+request = portal.REQUEST\n
+request.form.update(request_form)\n
+\n
+if skin_name and skin_name != \'None\': # make_query serializes None as \'None\'\n
+  portal.portal_skins.changeSkin(skin_name)\n
+\n
+report_data = getattr(context, deferred_style_dialog_method)(**params)\n
+\n
+attachment_name = [x[len(\'filename=\'):] for x in (request.RESPONSE.getHeader(\n
+                        \'content-disposition\') or \'\').split(\';\')\n
+                      if x.startswith(\'filename=\')][0]\n
+if attachment_name.startswith(\'"\'):\n
+  attachment_name = attachment_name[1:]\n
+if attachment_name.endswith(\'"\'):\n
+  attachment_name = attachment_name[:-1]\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
+# 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
+</string> </value>
+        </item>
+        <item>
+            <key> <string>_code</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>_params</string> </key>
+            <value> <string>localizer_language, skin_name, request_form, deferred_style_dialog_method, user_name, params</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>6</int> </value>
+                    </item>
+                    <item>
+                        <key> <string>co_varnames</string> </key>
+                        <value>
+                          <tuple>
+                            <string>localizer_language</string>
+                            <string>skin_name</string>
+                            <string>request_form</string>
+                            <string>deferred_style_dialog_method</string>
+                            <string>user_name</string>
+                            <string>params</string>
+                            <string>Products.ERP5Type.Message</string>
+                            <string>translateString</string>
+                            <string>_getattr_</string>
+                            <string>context</string>
+                            <string>portal</string>
+                            <string>request</string>
+                            <string>_apply_</string>
+                            <string>getattr</string>
+                            <string>report_data</string>
+                            <string>_getitem_</string>
+                            <string>append</string>
+                            <string>$append0</string>
+                            <string>_getiter_</string>
+                            <string>x</string>
+                            <string>len</string>
+                            <string>attachment_name</string>
+                            <string>attachment_list</string>
+                            <string>str</string>
+                            <string>False</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_renderSimpleView</string> </value>
+        </item>
+        <item>
+            <key> <string>warnings</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>

Modified: erp5/trunk/bt5/erp5_deferred_style/bt/change_log
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_deferred_style/bt/change_log?rev=31182&r1=31181&r2=31182&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_deferred_style/bt/change_log [utf8] (original)
+++ erp5/trunk/bt5/erp5_deferred_style/bt/change_log [utf8] Wed Dec  9 13:16:39 2009
@@ -1,0 +1,2 @@
+2009-09-12 Jérome
+* Allow rendering of any form / printout in deferred mode

Modified: erp5/trunk/bt5/erp5_deferred_style/bt/revision
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_deferred_style/bt/revision?rev=31182&r1=31181&r2=31182&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_deferred_style/bt/revision [utf8] (original)
+++ erp5/trunk/bt5/erp5_deferred_style/bt/revision [utf8] Wed Dec  9 13:16:39 2009
@@ -1,1 +1,1 @@
-67
+74




More information about the Erp5-report mailing list