Commit f4502b1f authored by Vincent Pelletier's avatar Vincent Pelletier

Duplicate ERP5Site_createModule to make it work woth xhtml style when the...

Duplicate ERP5Site_createModule to make it work woth xhtml style when the context rendering has no form (ie, on the portal object).

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@9152 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent bd846425
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
</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>from Products.Formulator.Errors import ValidationError, FormValidationError\n
\n
request=context.REQUEST\n
\n
# TODO\n
# - Allow in the module only the new document, we must activate the filter\n
# - handle an optionnal "description" parameter\n
# - set the form action to "Base_edit"\n
# - print : pdf\n
# - export : xml\n
# - report : last modified\n
# - security : 5A\n
\n
\n
portal = context.getPortalObject()\n
portal_types = portal.portal_types\n
object_portal_type_id = object_portal_type\n
\n
# Create a new portal_type for the module\n
context.portal_types.manage_addTypeInformation( \'ERP5 Type Information\'\n
, typeinfo_name = \'ERP5Type: ERP5 Folder\'\n
, id = module_portal_type\n
)\n
module_portal_type_value = context.portal_types[module_portal_type]\n
# Set allowed content types\n
# Following is not permitted in a python script\n
# context.portal_types[module_portal_type_value].allowed_content_types = (object_portal_type_id, )\n
# module_portal_type_value.edit( filter_content_types = 1\n
# , allowed_content_types = (object_portal_type_id, )\n
# )\n
action_list = module_portal_type_value.listActions()\n
module_portal_type_value.deleteActions(selections=range(0,len(action_list)))\n
# Parameters to addAction : id, name, action, condition, permission, category, visible=1, REQUEST=None\n
module_portal_type_value.addAction( "view"\n
, "View"\n
, "string:${object_url}/Folder_viewContentList"\n
, ""\n
, "View"\n
, "object_view"\n
)\n
module_portal_type_value.addAction( "sort_on"\n
, "Sort"\n
, "string:${object_url}/Folder_viewSortOnDialog"\n
, ""\n
, "View"\n
, "object_sort"\n
)\n
module_portal_type_value.addAction( "list_ui"\n
, "Modify UI"\n
, "string:${object_url}/Base_viewUIDialog"\n
, ""\n
, "View"\n
, "object_ui"\n
)\n
module_portal_type_value.addAction( "print_pdf"\n
, "Print"\n
, "string:${object_url}/Base_printPdf"\n
, ""\n
, "View"\n
, "object_print"\n
)\n
# Create the skin directory if does not exist yet\n
portal_skins_folder_name = portal_skins_folder\n
portal_skins = portal.portal_skins\n
if not portal.portal_skins.hasObject(portal_skins_folder_name):\n
portal_skins.manage_addFolder(portal_skins_folder_name)\n
skin_folder = portal.portal_skins[portal_skins_folder_name]\n
# Add new folders into skin paths.\n
for skin_name, selection in portal_skins.getSkinPaths():\n
selection = selection.split(\',\')\n
if portal_skins_folder_name not in selection:\n
new_selection = [portal_skins_folder_name,]\n
new_selection.extend(selection)\n
portal_skins.manage_skinLayers( skinpath = tuple(new_selection)\n
, skinname = skin_name\n
, add_skin = 1\n
)\n
\n
# Create the default ERP5 Form in order to view the object\n
form_view_id = object_portal_type_id.replace(\' \',\'\') + \'_view\'\n
factory = skin_folder.manage_addProduct[\'ERP5Form\']\n
factory.addERP5Form( form_view_id\n
, title = object_title\n
)\n
form_view_object = skin_folder[form_view_id]\n
form_view_object.rename_group(\'Default\', \'left\')\n
default_groups = [\'right\', \'center\', \'bottom\', \'hidden\']\n
for group in default_groups:\n
form_view_object.add_group(group)\n
\n
# Then add the portal_type corresponding to the new object\n
portal_types.manage_addTypeInformation(\'ERP5 Type Information\'\n
, typeinfo_name = \'ERP5Type: ERP5 Document\'\n
, id = object_portal_type_id\n
)\n
object_portal_type_value = portal_types[object_portal_type_id]\n
# Set default actions\n
action_list = object_portal_type_value.listActions()\n
object_portal_type_value.deleteActions(selections=range(0,len(action_list)))\n
# parameters to addAction : id, name, action, condition, permission, category, visible=1, REQUEST=None\n
object_portal_type_value.addAction( "view"\n
, "View"\n
, "string:${object_url}/%s" % form_view_id\n
, ""\n
, "View"\n
, "object_view"\n
, priority = 1\n
)\n
object_portal_type_value.addAction( "history"\n
, "History"\n
, "string:${object_url}/Base_viewHistory"\n
, ""\n
, "View"\n
, "object_view"\n
, priority = 2\n
)\n
object_portal_type_value.addAction( "metadata"\n
, "Metadata"\n
, "string:${object_url}/Base_viewMetadata"\n
, ""\n
, "Manage properties"\n
, "object_view"\n
, priority = 3\n
)\n
object_portal_type_value.addAction( "print_pdf"\n
, "Print"\n
, "string:${object_url}/Base_printPdf"\n
, ""\n
, "View"\n
, "object_print"\n
)\n
# Finally add the module to the site\n
module_object = portal.newContent( portal_type = module_portal_type\n
, id = module_id\n
, title = module_title\n
)\n
module_object.Base_setDefaultSecurity()\n
\n
return context.ERP5XhtmlStyle_redirect(cancel_url, keep_items={\'portal_status_message\': N_(\'Module created.\')}, **kw)\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_dav_writelocks</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>module_portal_type, portal_skins_folder, object_portal_type, object_title, module_id, module_title, **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>6</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>module_portal_type</string>
<string>portal_skins_folder</string>
<string>object_portal_type</string>
<string>object_title</string>
<string>module_id</string>
<string>module_title</string>
<string>kw</string>
<string>Products.Formulator.Errors</string>
<string>ValidationError</string>
<string>FormValidationError</string>
<string>_getattr_</string>
<string>context</string>
<string>request</string>
<string>portal</string>
<string>portal_types</string>
<string>object_portal_type_id</string>
<string>_getitem_</string>
<string>module_portal_type_value</string>
<string>action_list</string>
<string>range</string>
<string>len</string>
<string>portal_skins_folder_name</string>
<string>portal_skins</string>
<string>skin_folder</string>
<string>_getiter_</string>
<string>skin_name</string>
<string>selection</string>
<string>new_selection</string>
<string>tuple</string>
<string>form_view_id</string>
<string>factory</string>
<string>form_view_object</string>
<string>default_groups</string>
<string>group</string>
<string>object_portal_type_value</string>
<string>module_object</string>
<string>_apply_</string>
<string>cancel_url</string>
<string>N_</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>ERP5Site_createModule</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Persistence</string>
<string>PersistentMapping</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_container</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
79 81
\ No newline at end of file \ 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