Commit a2a46783 authored by Romain Courteaud's avatar Romain Courteaud

WIP access for jIO.

Accessing data is done through a web site, in order to surcharge the low level
erp5 scripts/templates/etc.
Navigation is handle with a HATEOAS API.
parent 402f743a
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Site" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Authenticated</string>
<string>Author</string>
<string>Manager</string>
<string>Member</string>
<string>Owner</string>
<string>Reviewer</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_folders_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Copy_or_Move_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Delete_objects_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Authenticated</string>
<string>Author</string>
<string>Manager</string>
<string>Member</string>
<string>Owner</string>
<string>Reviewer</string>
</tuple>
</value>
</item>
<item>
<key> <string>__before_publishing_traverse__</string> </key>
<value>
<object>
<klass>
<global name="MultiHook" module="ZPublisher.BeforeTraverse"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_defined_in_class</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>_hookname</string> </key>
<value> <string>__before_publishing_traverse__</string> </value>
</item>
<item>
<key> <string>_list</string> </key>
<value>
<list>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</list>
</value>
</item>
<item>
<key> <string>_prior</string> </key>
<value>
<none/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>__before_traverse__</string> </key>
<value>
<dictionary>
<item>
<key>
<tuple>
<int>99</int>
<string>ERP5 Web Site/hateoas</string>
</tuple>
</key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>available_language</string> </key>
<value>
<tuple>
<string>en</string>
</tuple>
</value>
</item>
<item>
<key> <string>container_layout</string> </key>
<value> <string>ERP5Document_getHateoas</string> </value>
</item>
<item>
<key> <string>content_layout</string> </key>
<value> <string>ERP5Document_getHateoas</string> </value>
</item>
<item>
<key> <string>custom_render_method_id</string> </key>
<value> <string>ERP5Document_getHateoas</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>hateoas</string> </value>
</item>
<item>
<key> <string>layout_configuration_form_id</string> </key>
<value> <string>WebSection_viewDefaultThemeConfiguration</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Site</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>skin_selection_name</string> </key>
<value> <string>Hal</string> </value>
</item>
<item>
<key> <string>static_language_selection</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Hateoas</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="WebSiteTraversalHook" module="Products.ERP5.Document.WebSite"/>
</pickle>
<pickle>
<dictionary/>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>category_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAY=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAc=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="6" aka="AAAAAAAAAAY=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global id="6.1" name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1389184989.74</float>
<string>GMT+1</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>embedded</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass> <reference id="6.1"/> </klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1389189442.06</float>
<string>GMT+1</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="7" aka="AAAAAAAAAAc=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>0.0.0.0</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global id="7.1" name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1389184989.76</float>
<string>GMT+1</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>931.64347.10874.21742</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass> <reference id="7.1"/> </klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1389185048.01</float>
<string>GMT+1</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>931.64348.8944.3754</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass> <reference id="7.1"/> </klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1389188952.06</float>
<string>GMT+1</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>931.64413.13210.41147</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass> <reference id="7.1"/> </klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1389189094.15</float>
<string>GMT+1</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>931.64415.37368.5734</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass> <reference id="7.1"/> </klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1389189246.84</float>
<string>GMT+1</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>931.64418.7534.16605</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass> <reference id="7.1"/> </klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1389189258.78</float>
<string>GMT+1</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>931.64418.20526.19592</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass> <reference id="7.1"/> </klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1389189270.11</float>
<string>GMT+1</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>931.64418.32911.29252</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass> <reference id="7.1"/> </klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1389189338.87</float>
<string>GMT+1</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>931.64421.24176.45243</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass> <reference id="7.1"/> </klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1389263264.87</float>
<string>GMT+1</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>932.115.50753.2764</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass> <reference id="7.1"/> </klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1389263536.53</float>
<string>GMT+1</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>932.120.18159.59989</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass> <reference id="7.1"/> </klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1389263689.67</float>
<string>GMT+1</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
<registered_skin_selection>
<skin_folder_selection>
<skin_folder>erp5_hal_json_style</skin_folder>
<skin_selection>Hal</skin_selection>
</skin_folder_selection>
<skin_folder_selection>
<skin_folder>erp5_km_theme</skin_folder>
<skin_selection>Hal</skin_selection>
</skin_folder_selection>
<skin_folder_selection>
<skin_folder>erp5_xhtml_style</skin_folder>
<skin_selection>Hal</skin_selection>
</skin_folder_selection>
<skin_folder_selection>
<skin_folder>vifib_hosting</skin_folder>
<skin_selection>Hal</skin_selection>
</skin_folder_selection>
<skin_folder_selection>
<skin_folder>vifib_hosting_theme</skin_folder>
<skin_selection>Hal</skin_selection>
</skin_folder_selection>
<skin_folder_selection>
<skin_folder>vifib_jauks_theme</skin_folder>
<skin_selection>Hal</skin_selection>
</skin_folder_selection>
<skin_folder_selection>
<skin_folder>vifib_jauks_widget_library</skin_folder>
<skin_selection>Hal</skin_selection>
</skin_folder_selection>
<skin_folder_selection>
<skin_folder>vifib_web</skin_folder>
<skin_selection>Hal</skin_selection>
</skin_folder_selection>
</registered_skin_selection>
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>business_template_skin_layer_priority</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>float</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>business_template_skin_layer_priority</string> </key>
<value> <float>99.0</float> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>erp5_hal_json_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>
<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 encoding="cdata"><![CDATA[
"""\n
This script validates a form to the current REQUEST,\n
processes the REQUEST to extract form data and editors,\n
then updates the current context with the form data\n
by calling edit on it or by invoking editors.\n
\n
TODO: split the generic form validation logic\n
from the context update logic\n
"""\n
from Products.Formulator.Errors import FormValidationError\n
from Products.CMFActivity.Errors import ActivityPendingError\n
\n
request=container.REQUEST\n
portal = context.getPortalObject()\n
Base_translateString = portal.Base_translateString\n
\n
# Extra security\n
if request.get(\'field_prefix\', None):\n
field_prefix = \'my_\' # Prevent changing the prefix through publisher\n
\n
# Use dialog_id if present, otherwise fall back on form_id.\n
if dialog_id not in (\'\', None):\n
form_id = dialog_id\n
\n
# Prevent users who don\'t have rights to edit the object from\n
# editing it by calling the Base_edit script with correct\n
# parameters directly.\n
if not silent_mode and not request.AUTHENTICATED_USER.has_permission(\'Modify portal content\', context) :\n
msg = Base_translateString("You do not have the permissions to edit the object.")\n
redirect_url = \'%s/%s?selection_index=%s&selection_name=%s&%s\' % (context.absolute_url(), form_id, selection_index, selection_name, \'portal_status_message=%s\' % msg)\n
# return request[\'RESPONSE\'].redirect(redirect_url)\n
return context.Base_redirect(redirect_url)\n
\n
# Get the form\n
form = getattr(context,form_id)\n
edit_order = form.edit_order\n
\n
try:\n
# Validate\n
form.validate_all_to_request(request, key_prefix=key_prefix)\n
except FormValidationError, validation_errors:\n
# Pack errors into the request\n
field_errors = form.ErrorFields(validation_errors)\n
request.set(\'field_errors\', field_errors)\n
# Make sure editors are pushed back as values into the REQUEST object\n
for f in form.get_fields():\n
field_id = f.id\n
if request.has_key(field_id):\n
value = request.get(field_id)\n
if callable(value):\n
value(request)\n
if silent_mode: return form(request), \'form\'\n
return form(request)\n
\n
def editListBox(listbox_field, listbox):\n
""" Function called to edit a listbox\n
"""\n
if listbox is not None:\n
gv = {}\n
if listbox_field.has_value(\'global_attributes\'):\n
hidden_attributes = map(lambda x:x[0], listbox_field.get_value(\'global_attributes\'))\n
for k in hidden_attributes:\n
gv[k] = getattr(request, k, None)\n
for url, v in listbox.items():\n
v.update(gv)\n
# Form: \'\' -> ERP5: None\n
cleaned_v = v.copy()\n
for key, value in cleaned_v.items():\n
if value == \'\':\n
cleaned_v[key] = None\n
if listbox_edit is None:\n
context.restrictedTraverse(url).edit(edit_order=edit_order, **cleaned_v)\n
else:\n
listbox_edit(url, edit_order, cleaned_v)\n
\n
def editMatrixBox(matrixbox_field, matrixbox):\n
""" Function called to edit a Matrix box\n
"""\n
if matrixbox is not None:\n
cell_base_id = matrixbox_field.get_value(\'cell_base_id\')\n
portal_type = matrixbox_field.get_value(\'cell_portal_type\')\n
getter_method = matrixbox_field.get_value(\'getter_method\')\n
if getter_method not in (None, \'\'):\n
matrix_context = getattr(context,getter_method)()\n
else:\n
matrix_context = context\n
if matrix_context is not None:\n
kd = {}\n
kd[\'portal_type\'] = portal_type\n
kd[\'base_id\'] = cell_base_id\n
gv = {}\n
if matrixbox_field.has_value(\'global_attributes\'):\n
hidden_attributes = [x[0] for x in matrixbox_field.get_value(\'global_attributes\')]\n
for k in hidden_attributes:\n
gv[k] = getattr(request, k, None)\n
if matrixbox_field.get_value(\'update_cell_range\'):\n
as_cell_range_script_id = matrixbox_field.get_value(\n
\'as_cell_range_script_id\')\n
lines = []\n
columns = []\n
tabs = []\n
extra_dimension_list_list = []\n
if as_cell_range_script_id:\n
cell_range = getattr(matrix_context,\n
as_cell_range_script_id)(matrixbox=True, base_id=cell_base_id)\n
if len(cell_range) == 1:\n
lines, = cell_range\n
elif len(cell_range) == 2:\n
lines, columns = cell_range\n
elif len(cell_range) == 3:\n
lines, columns, tabs = cell_range\n
elif len(cell_range) > 3:\n
lines = cell_range[0]\n
columns = cell_range[1]\n
tabs = cell_range[2]\n
extra_dimension_list_list = cell_range[3:]\n
else:\n
lines = matrixbox_field.get_value(\'lines\')\n
columns = matrixbox_field.get_value(\'columns\')\n
tabs = matrixbox_field.get_value(\'tabs\')\n
\n
column_ids = map(lambda x: x[0], columns)\n
line_ids = map(lambda x: x[0], lines)\n
tab_ids = map(lambda x: x[0], tabs)\n
extra_dimension_category_list_list = [[category for category, label in dimension_list] for dimension_list in extra_dimension_list_list]\n
\n
# There are 3 cases\n
# Case 1: we do 1 dimensional matrix\n
# Case 2: we do 2 dimensional matrix\n
# Case 3: we do 2 dimensional matrix + tabs\n
# Case 4: we do 2 dimensional matrix + tabs + extra\n
cell_range = matrix_context.getCellRange(base_id = cell_base_id)\n
if (len(column_ids) == 0) or (column_ids[0] is None):\n
matrixbox_cell_range = [line_ids]\n
if cell_range != matrixbox_cell_range:\n
matrix_context.setCellRange(line_ids, base_id=cell_base_id)\n
\n
elif (len(tab_ids) == 0) or (tab_ids[0] is None):\n
matrixbox_cell_range = [line_ids, column_ids]\n
if cell_range != matrixbox_cell_range:\n
matrix_context.setCellRange(line_ids, column_ids, base_id=cell_base_id)\n
\n
else:\n
matrixbox_cell_range = [line_ids, column_ids, tab_ids]\n
if extra_dimension_category_list_list:\n
matrixbox_cell_range = matrixbox_cell_range + extra_dimension_category_list_list\n
if cell_range != matrixbox_cell_range:\n
matrix_context.setCellRange(base_id=cell_base_id, *matrixbox_cell_range)\n
\n
for k,v in matrixbox.items():\n
# Only update cells which still exist\n
if matrix_context.hasInRange(*k, **kd):\n
c = matrix_context.newCell(*k, **kd)\n
if c is not None:\n
c.edit(edit_order=edit_order, **gv) # First update globals which include the def. of property_list\n
if v.has_key(\'variated_property\'):\n
# For Variated Properties\n
value = v[\'variated_property\']\n
del v[\'variated_property\']\n
if gv.has_key(\'mapped_value_property_list\'):\n
# Change the property which is defined by the\n
# first element of mapped_value_property_list\n
# XXX May require some changes with Sets\n
key = gv[\'mapped_value_property_list\'][0]\n
v[key] = value\n
# Form: \'\' -> ERP5: None\n
cleaned_v = v.copy()\n
for key, value in cleaned_v.items():\n
if value == \'\':\n
cleaned_v[key] = None\n
c.edit(edit_order=edit_order, **cleaned_v) # and update the cell specific values\n
else:\n
return "Could not create cell %s" % str(k)\n
else:\n
return "Cell %s does not exist" % str(k)\n
\n
field_prefix_len = len(field_prefix)\n
\n
def parseField(f):\n
"""\n
Parse given form field, to put them in\n
kw or in encapsulated_editor_list\n
"""\n
k = f.id\n
if f.has_value(\'alternate_name\'):\n
k = f.get_value(\'alternate_name\') or f.id\n
v = getattr(request, k, MARKER)\n
if hasattr(v, \'edit\'):\n
# This is an encapsulated editor\n
# call it\n
encapsulated_editor_list.append(v)\n
elif v is not MARKER:\n
if k.startswith(field_prefix):\n
# We only take into account\n
# the object attributes\n
k = k[field_prefix_len:]\n
# Form: \'\' -> ERP5: None\n
if v == \'\':\n
v = None\n
kw[k] = v\n
\n
# Some initilizations\n
kw = {}\n
encapsulated_editor_list = []\n
MARKER = []\n
message = Base_translateString("Data updated.")\n
\n
try:\n
# We process all the field in form and\n
# we check if they are in the request,\n
# then we edit them\n
for field in form.get_fields():\n
parseField(field)\n
\n
## XXX We need to find a way not to use meta_type.\n
field_meta_type = field.meta_type\n
if field_meta_type == \'ProxyField\':\n
field_meta_type = field.getRecursiveTemplateField().meta_type\n
\n
if(field_meta_type == \'ListBox\'):\n
editListBox(field, request.get(field.id))\n
elif(field_meta_type == \'MatrixBox\'):\n
editMatrixBox(field, request.get(field.id))\n
\n
# Return parsed values \n
if silent_mode: return (kw, encapsulated_editor_list), \'edit\'\n
\n
# Maybe we should build a list of objects we need\n
# Update basic attributes\n
context.edit(REQUEST=request, edit_order=edit_order, **kw)\n
for encapsulated_editor in encapsulated_editor_list:\n
encapsulated_editor.edit(context)\n
except ActivityPendingError,e:\n
message = Base_translateString("%s" % e)\n
\n
ignore_layout = int(ignore_layout)\n
try:\n
editable_mode = int(editable_mode)\n
except TypeError:\n
raise TypeError(str(editable_mode))\n
spp = context.getPhysicalPath()\n
spp =list(spp)\n
s_url = request["SERVER_URL"]\n
spp.insert(0,s_url)\n
#calculate direct the url instead of using absolute_url\n
new_url = \'/\'.join(spp)\n
\n
# for web mode, we should use \'view\' instead of passed form_id\n
# after \'Save & View\'.\n
if context.REQUEST.get(\'is_web_mode\', False) and \\\n
not editable_mode:\n
form_id = \'view\'\n
\n
if not selection_index:\n
# redirect_url = \'%s/%s?ignore_layout:int=%s&editable_mode:int=%s&portal_status_message=%s\' % (\n
# context.absolute_url(),\n
redirect_url = \'%s?ignore_layout:int=%s&editable_mode:int=%s&portal_status_message=%s\' % (\n
form_id,\n
ignore_layout,\n
editable_mode,\n
message)\n
\n
\n
else:\n
# redirect_url = \'%s/%s?selection_index=%s&selection_name=%s&ignore_layout:int=%s&editable_mode=%s&portal_status_message=%s\' % (\n
# context.absolute_url(),\n
redirect_url = \'%s?selection_index=%s&selection_name=%s&ignore_layout:int=%s&editable_mode=%s&portal_status_message=%s\' % (\n
form_id,\n
selection_index,\n
selection_name,\n
ignore_layout,\n
editable_mode,\n
message)\n
\n
\n
# result = request[\'RESPONSE\'].redirect(redirect_url) \n
\n
if silent_mode: return result, \'redirect\'\n
return context.Base_redirect(redirect_url)\n
# return result\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>form_id, selection_index=0, selection_name=\'\', dialog_id=\'\', ignore_layout=0, editable_mode=1, silent_mode=0, field_prefix=\'my_\', key_prefix=None, listbox_edit=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_edit</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>from zExceptions import Unauthorized\n
if REQUEST is not None:\n
raise Unauthorized\n
\n
# XXX requested to simulate in unit test for now\n
return context.REQUEST.get(\'BODY\')\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getRequestBody</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>from zExceptions import Unauthorized\n
if REQUEST is not None:\n
raise Unauthorized\n
\n
# XXX requested to simulate in unit test for now\n
return context.REQUEST.getHeader(name, default)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>name, default=None, REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getRequestHeader</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>from zExceptions import Unauthorized\n
if REQUEST is not None:\n
raise Unauthorized\n
\n
# XXX requested to simulate in unit test for now\n
return context.REQUEST.getURL()\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getRequestUrl</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>from zExceptions import Unauthorized\n
if REQUEST is not None:\n
raise Unauthorized\n
\n
result = None\n
accept = context.Base_getRequestHeader(\'Accept\', default=\'\')\n
for accepted_type in accepted_type_list:\n
if accepted_type in accept:\n
# XXX Really simple and stupid matching.\n
# Better test to ensure best matching type\n
result = accepted_type\n
break\n
\n
if (result is None) and (\'*/*\' in accept):\n
result = accepted_type_list[0]\n
\n
return result\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>accepted_type_list, REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_handleAcceptHeader</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>from zExceptions import Unauthorized\n
if REQUEST is not None:\n
raise Unauthorized\n
\n
RESPONSE.setHeader("Access-Control-Allow-Credentials", "true")\n
RESPONSE.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept")\n
RESPONSE.setHeader("Access-Control-Allow-Methods", "GET, OPTIONS, HEAD, DELETE, PUT, POST")\n
RESPONSE.setHeader("Access-Control-Allow-Origin", context.Base_getRequestHeader("Origin"))\n
RESPONSE.setHeader("Access-Control-Expose-Headers", "Content-Type, Content-Length, WWW-Authenticate, Location")\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None, RESPONSE=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_prepareCorsResponse</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 encoding="cdata"><![CDATA[
"""\n
This script factorises code required to redirect to the appropriate\n
page from a script. It should probably be extended, reviewed and documented\n
so that less code is copied and pasted in dialog scripts.\n
\n
TODO: improve API and extensively document. ERP5Site_redirect may \n
be redundant.\n
"""\n
from ZTUtils import make_query\n
request_form = context.REQUEST.form\n
request_form.update(kw)\n
request_form = context.ERP5Site_filterParameterList(request_form)\n
request_form.update(keep_items)\n
\n
if form_id == \'view\':\n
redirect_url = context.absolute_url()\n
else:\n
redirect_url = \'%s/%s\' % (context.absolute_url(), form_id)\n
\n
parameters = make_query(dict([(k, v) for k, v in request_form.items() if k and v is not None]))\n
if len(parameters):\n
if \'?\' in redirect_url:\n
separator = \'&\'\n
else:\n
separator = \'?\'\n
redirect_url = \'%s%s%s\' % (redirect_url, separator, parameters)\n
\n
\n
# XXX Allow CORS\n
response = context.REQUEST.RESPONSE\n
context.Base_prepareCorsResponse(RESPONSE=response)\n
# http://en.wikipedia.org/wiki/Post/Redirect/Get\n
response.setStatus(201)\n
response.setHeader("Location", redirect_url)\n
return\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>form_id=\'view\', keep_items={}, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_redirect</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 encoding="cdata"><![CDATA[
from zExceptions import Unauthorized\n
from AccessControl import getSecurityManager\n
import json\n
if REQUEST is None:\n
REQUEST = context.REQUEST\n
# raise Unauthorized\n
if response is None:\n
response = REQUEST.RESPONSE\n
\n
def renderField(field, meta_type=None):\n
if meta_type is None:\n
meta_type = field.meta_type\n
\n
if meta_type == "ProxyField":\n
result = renderField(field, meta_type=field.getRecursiveTemplateField().meta_type)\n
elif meta_type in ("ListField", "ParallelListField", "MultiListField"):\n
result = {\n
"type": meta_type,\n
"key": field.generate_field_key(),\n
"default": field.get_value("default"),\n
"editable": field.get_value("editable"),\n
"css_class": field.get_value("css_class"),\n
"hidden": field.get_value("hidden"),\n
"description": field.get_value("description"),\n
"title": field.get_value("title"),\n
"required": field.get_value("required"),\n
# XXX Message can not be converted to json as is\n
# "items": field.get_value("items"),\n
}\n
elif meta_type in ("StringField", "FloatField", "RelationStringField",\n
"MultiRelationStringField", "EmailField", "TextAreaField",\n
"LinesField", "ImageField", "FileField", "IntegerField",\n
"PasswordField"):\n
result = {\n
"type": meta_type,\n
"key": field.generate_field_key(),\n
"default": field.get_value("default"),\n
"editable": field.get_value("editable"),\n
"css_class": field.get_value("css_class"),\n
"hidden": field.get_value("hidden"),\n
"description": field.get_value("description"),\n
"title": field.get_value("title"),\n
"required": field.get_value("required"),\n
}\n
elif meta_type == "ListBox":\n
# XXX Not implemented\n
columns = field.get_value("columns")\n
\n
list_method = getattr(context, context.Listbox_getListMethodName(field))\n
portal_types = [x[1] for x in field.get_value(\'portal_types\')]\n
default_params = dict(field.get_value(\'default_params\'))\n
default_params.update(REQUEST.form)\n
lines = field.get_value(\'lines\')\n
row_list = list_method(limit=lines, portal_type=portal_types,\n
**default_params)\n
line_list = []\n
for row in row_list:\n
document = row.getObject()\n
line = {\n
\'url\': "%s/ERP5Document_getHateoas?portal_skin=Hal" % document.absolute_url(),\n
}\n
for property, title in columns:\n
prop = document.getProperty(property)\n
if same_type(prop, DateTime()):\n
prop = "XXX Serialize DateTime" \n
line[title] = prop\n
line_list.append(line)\n
\n
result = {\n
"type": meta_type,\n
"column_list": [x[1] for x in columns],\n
"line_list": line_list,\n
}\n
else:\n
# XXX Not implemented\n
result = {\n
"type": meta_type,\n
"_debug": "Unsupported field type"\n
}\n
return result\n
\n
\n
def renderForm(form, response_dict):\n
REQUEST.set(\'here\', context)\n
\n
# Form action\n
response_dict[\'_actions\'] = {\n
\'put\': {\n
"href": "%s/%s" % (context.absolute_url(), form.action),\n
"method": form.method,\n
}\n
}\n
# Form context\n
response_dict[\'_links\'][\'context\'] = {\n
"href": "%s/%s" % (context.absolute_url(), script.id),\n
"name": context.getRelativeUrl(),\n
"title": context.getTitle()\n
}\n
\n
# # XXX form action update, etc\n
# def renderRawField(field):\n
# meta_type = field.meta_type\n
# if meta_type == "MethodField":\n
# result = {\n
# "meta_type": field.meta_type\n
# }\n
# else:\n
# result = {\n
# "meta_type": field.meta_type,\n
# "_values": field.values,\n
# # XXX TALES expression is not JSON serializable by default\n
# # "_tales": field.tales\n
# "_overrides": field.overrides\n
# }\n
# if meta_type == "ProxyField":\n
# result[\'_delegated_list\'] = field.delegated_list\n
# # try:\n
# # result[\'_delegated_list\'].pop(\'list_method\')\n
# # except KeyError:\n
# # pass\n
# \n
# # XXX ListMethod is not JSON serialized by default\n
# try:\n
# result[\'_values\'].pop(\'list_method\')\n
# except KeyError:\n
# pass\n
# try:\n
# result[\'_overrides\'].pop(\'list_method\')\n
# except KeyError:\n
# pass\n
# return result\n
# \n
\n
group_list = []\n
for group in form.Form_getGroupTitleAndId():\n
\n
if group[\'gid\'].find(\'hidden\') < 0:\n
# field_list = []\n
for field in form.get_fields_in_group(group[\'goid\']):\n
# field_list.append((field.id, renderRawField(field)))\n
if field.get_value("enabled"):\n
response_dict[field.id] = renderField(field)\n
\n
# for field_group in field.form.get_groups():\n
# context.log("Field group: " + field_group)\n
# context.log(field_group)\n
# for field_property in field.form.get_fields_in_group(field_group):\n
# # context.log("Field attribute: " + field_property.id)\n
# # field.get_value(field_property.id)\n
# context.log(field_property)\n
\n
# group_list.append((group[\'gid\'], field_list))\n
# \n
# group_list[-1][1].append(("form_id", {\n
# "type": "StringField",\n
# "key": "form_id",\n
# "default": form.id,\n
# "editable": 0,\n
# "css_class": "",\n
# "hidden": 1,\n
# "description": "",\n
# "title": "form_id",\n
# "required": 1,\n
# }))\n
# \n
# response_dict["group_list"] = group_list\n
# rendered_response_dict["_embedded"] = {\n
# "form": raw_response_dict\n
# }\n
\n
\n
context.Base_prepareCorsResponse(RESPONSE=response)\n
\n
mime_type = \'application/hal+json\'\n
portal = context.getPortalObject()\n
\n
# Calculate the site root to prevent unexpected browsing\n
is_web_mode = (context.REQUEST.get(\'current_web_section\', None) is not None) or context.isWebMode()\n
# is_web_mode = context.isWebMode()\n
if is_web_mode:\n
site_root = context.getWebSiteValue()\n
else:\n
site_root = portal\n
\n
# Check if context is the site_root\n
is_site_root = (context.getPath() == site_root.getPath())\n
is_portal = (context.getPath() == portal.getPath())\n
\n
result_dict = {\n
\'_debug\': mode,\n
\'_links\': {\n
"self": {\n
"href": context.Base_getRequestUrl()\n
},\n
# Always inform about site root\n
"site_root": {\n
"href": "%s/%s" % (site_root.absolute_url(), script.id),\n
"name": site_root.getTitle(),\n
}\n
}\n
}\n
\n
\n
if mime_type != context.Base_handleAcceptHeader([mime_type]):\n
response.setStatus(406)\n
return ""\n
\n
\n
elif mode == \'document\':\n
#################################################\n
# Raw document\n
#################################################\n
if REQUEST.other[\'method\'] != "GET":\n
response.setStatus(405)\n
return ""\n
# Default properties shared by all ERP5 Document and Site\n
action_dict = {}\n
result_dict[\'_relative_url\'] = context.getRelativeUrl()\n
\n
# Add a link to the portal type if possible\n
if not is_portal:\n
result_dict[\'_links\'][\'type\'] = {\n
"href": "%s/%s" % (portal.portal_types[context.getPortalType()].absolute_url(), script.id),\n
"name": context.getPortalType(),\n
}\n
\n
# XXX Loop on form rendering\n
erp5_action_dict = portal.Base_filterDuplicateActions(\n
portal.portal_actions.listFilteredActionsFor(context))\n
\n
embedded_url = None\n
embedded_action_key = None\n
# XXX See ERP5Type.getDefaultViewFor\n
for erp5_action_key in erp5_action_dict.keys():\n
erp5_action_list = []\n
for view_action in erp5_action_dict[erp5_action_key]:\n
# Action condition is probably checked in Base_filterDuplicateActions\n
erp5_action_list.append({\n
\'href\': \'%s\' % view_action[\'url\'],\n
\'name\': view_action[\'id\'],\n
\'title\': view_action[\'title\']\n
})\n
# Try to embed the form in the result\n
if (view == view_action[\'id\']):\n
embedded_url = \'%s\' % view_action[\'url\']\n
embedded_action_key = "action_" + erp5_action_key\n
\n
if erp5_action_list:\n
if len(erp5_action_list) == 1:\n
erp5_action_list = erp5_action_list[0]\n
# XXX Put a prefix to prevent conflict\n
result_dict[\'_links\']["action_" + erp5_action_key] = erp5_action_list\n
\n
# for view_action in erp5_action_dict.get(\'object_view\', []):\n
# context.log(view_action)\n
# # XXX Check the action condition\n
# # if (view is None) or (view != view_action[\'name\']):\n
# object_view_list.append({\n
# \'href\': \'%s\' % view_action[\'url\'],\n
# \'name\': view_action[\'name\']\n
# })\n
\n
# # XXX Check that context is not the portal\n
# if (context.getRelativeUrl() != portal.getRelativeUrl()) and (context.getRelativeUrl() != site_root.getRelativeUrl()):\n
# parent = context.getParentValue()\n
# if (is_web_mode and (parent.getRelativeUrl() != portal.getRelativeUrl())):\n
# result_dict[\'_links\'][\'parent\'] = {\n
# \'href\': \'%s\' % parent.absolute_url(),\n
# \'name\': parent.getTitle()\n
# }\n
# \n
# if (renderer_form is not None):\n
# context_property_dict, renderer_form_json = context.Base_renderFormAsSomething(renderer_form)\n
# result_dict[\'_embedded\'] = {\n
# \'object_view\': renderer_form_json\n
# }\n
# result_dict.update(context_property_dict)\n
\n
# XXX XXX XXX XXX\n
if (embedded_url is not None):\n
# XXX Try to fetch the form in the context of the document\n
# Of course, this code will completely crash in many cases (page template\n
# instead of form, unexpected action TALES expression). Happy debugging.\n
# renderer_form_relative_url = view_action[\'url\'][len(portal.absolute_url()):]\n
form_id = embedded_url.split(\'?\', 1)[0].split("/")[-1]\n
# XXX Drop (or do something else...) all query parameters (?reset:int=1)\n
renderer_form = context.restrictedTraverse(form_id, None)\n
# XXX Proxy field are not correctly handled in context of web site\n
renderer_form = getattr(context, form_id)\n
context.log(form_id)\n
if (renderer_form is not None):\n
embedded_dict = {\n
\'_links\': {\n
\'self\': {\n
\'href\': embedded_url\n
}\n
}\n
}\n
renderForm(renderer_form, embedded_dict)\n
result_dict[\'_embedded\'] = {\n
\'_view\': embedded_dict\n
# embedded_action_key: embedded_dict\n
}\n
\n
# Include properties in document JSON\n
# XXX Extract from renderer form?\n
for group in renderer_form.Form_getGroupTitleAndId():\n
for field in renderer_form.get_fields_in_group(group[\'goid\']):\n
field_id = field.id\n
context.log(field_id)\n
if field_id.startswith(\'my_\'):\n
property_name = field_id[len(\'my_\'):]\n
context.log(property_name)\n
property_value = context.getProperty(property_name, d=None)\n
if (property_value is not None):\n
if not same_type(property_value, DateTime()):\n
# XXX Serialize DateTime\n
result_dict[property_name] = property_value \n
\n
if is_site_root:\n
# Global action users for the jIO plugin\n
# XXX Would be better to not hardcode them but put them as portal type\n
# "actions" (search could be on portal_catalog document, traverse on all\n
# documents, newContent on all, etc)\n
# result_dict[\'_links\'][\'object_search\'] = {\n
# \'href\': \'%s/ERP5Site_viewSearchForm?portal_skin=Hal\' % absolute_url,\n
# \'name\': \'Global Search\'\n
# }\n
result_dict[\'_links\'][\'raw_search\'] = {\n
"href": "%s/%s?mode=search{&query,select_list*,limit*}" % (site_root.absolute_url(), script.id),\n
\'name\': \'Raw Search\',\n
\'templated\': True\n
}\n
result_dict[\'_links\'][\'traverse\'] = {\n
\'href\': \'%s/{+relative_url}/%s{?view}\' % (site_root.absolute_url(), script.id),\n
\'name\': \'Traverse\',\n
\'templated\': True\n
}\n
action_dict[\'add\'] = {\n
\'href\': "%s/%s?mode=newContent" % (site_root.absolute_url(), script.id),\n
\'method\': \'POST\',\n
\'name\': \'New Content\',\n
}\n
\n
# Handle also other kind of users: instance, computer, master\n
person = portal.ERP5Site_getAuthenticatedMemberPersonValue()\n
if person is not None:\n
result_dict[\'_links\'][\'me\'] = {\n
\'href\': \'%s/%s\' % (person.absolute_url(), script.id),\n
}\n
\n
# Define document action\n
if action_dict:\n
result_dict[\'_actions\'] = action_dict\n
\n
\n
elif mode == \'search\':\n
#################################################\n
# Portal catalog search\n
#################################################\n
if REQUEST.other[\'method\'] != "GET":\n
response.setStatus(405)\n
return ""\n
# XXX\n
length = len(\'/%s/\' % portal.getId())\n
sql_list = context.portal_catalog(full_text=query, limit=limit)\n
result_list = []\n
\n
if (select_list is None):\n
# Only include links\n
for sql_document in sql_list:\n
document = sql_document.getObject()\n
result_list.append({\n
\'href\': \'%s/%s\' % (document.absolute_url(), script.id),\n
})\n
result_dict[\'_links\'][\'contents\'] = result_list\n
\n
else:\n
for sql_document in sql_list:\n
document = sql_document.getObject()\n
document_result = {\n
\'_relative_url\': sql_document.path[length:],\n
\'_links\': {\n
\'self\': {\'href\': \'%s/%s\' % (document.absolute_url(), script.id)},\n
}\n
}\n
for select in select_list:\n
document_result[select] = document.getProperty(select, d=None)\n
result_list.append(document_result)\n
result_dict[\'_embedded\'] = {"contents": result_list}\n
\n
\n
elif mode == \'newContent\':\n
#################################################\n
# Create new document\n
#################################################\n
if REQUEST.other[\'method\'] != "POST":\n
response.setStatus(405)\n
return ""\n
# # XXX SlapOS custom API\n
# portal_type = REQUEST.form["portal_type"]\n
# if portal_type == "Computer":\n
# person = portal.ERP5Site_getAuthenticatedMemberPersonValue()\n
# request_kw = dict(computer_title=REQUEST.form["title"])\n
# person.requestComputer(**request_kw)\n
# computer = context.restrictedTraverse(context.REQUEST.get(\'computer\'))\n
# return computer.Base_redirect(form_id=script.id)\n
# \n
# elif portal_type == "Computer Network":\n
# # XXX Copy/Paste from WebSection_registerNewNetwork\n
# reference = "NET-%s" % portal.portal_ids.generateNewId(\n
# id_group=\'slap_network_reference\',\n
# id_generator=\'uid\')\n
# module = portal.getDefaultModule(portal_type=portal_type)\n
# network = module.newContent(\n
# portal_type=portal_type,\n
# title=REQUEST.form["title"],\n
# reference=reference,\n
# source_administration=context.ERP5Site_getAuthenticatedMemberPersonValue().getRelativeUrl()\n
# )\n
# network.validate()\n
# return network.Base_redirect(form_id=script.id)\n
# \n
# else:\n
# raise NotImplementedError, "Can not add %s" % portal_type\n
# return ""\n
\n
raise NotImplementedError, "Can not add %s" % portal_type\n
\n
\n
elif mode == \'form\':\n
#################################################\n
# Calculate form value\n
#################################################\n
if REQUEST.other[\'method\'] != "GET":\n
response.setStatus(405)\n
return ""\n
\n
renderForm(form, result_dict)\n
\n
\n
else:\n
raise NotImplementedError, "Unsupported mode %s" % mode\n
\n
response.setHeader(\'Content-Type\', mime_type)\n
return json.dumps(result_dict, indent=2)\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None, response=None, view=None, mode=\'document\', query=None, select_list=None, limit=None, form=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Document_getHateoas</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ExternalMethod" module="Products.ExternalMethod.ExternalMethod"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_function</string> </key>
<value> <string>Listbox_getListMethodName</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>HalStyle</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Listbox_getListMethodName</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>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<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> <unicode encoding="cdata"><![CDATA[
<tal:block tal:content="python: here.ERP5Document_getHateoas(form=form, REQUEST=request, mode=\'form\')" />
]]></unicode> </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>form_dialog</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<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> <unicode encoding="cdata"><![CDATA[
<tal:block tal:content="python: here.ERP5Document_getHateoas(form=form, REQUEST=request, mode=\'form\')" />
]]></unicode> </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>form_list</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<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> <unicode encoding="cdata"><![CDATA[
<tal:block tal:content="python: here.ERP5Document_getHateoas(form=form, REQUEST=request, mode=\'form\')" />
]]></unicode> </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>form_view</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
slapos_web
\ No newline at end of file
GPL
\ No newline at end of file
1
\ No newline at end of file
web_site_module/hateoas
\ No newline at end of file
web_site_module/hateoas
web_site_module/hateoas/**
\ No newline at end of file
erp5_hal_json_style | Hal
erp5_km_theme | Hal
erp5_xhtml_style | Hal
vifib_hosting | Hal
vifib_hosting_theme | Hal
vifib_jauks_theme | Hal
vifib_jauks_widget_library | Hal
vifib_web | Hal
\ No newline at end of file
erp5_hal_json_style
\ No newline at end of file
slapos_jio
\ No newline at end of file
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