<?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[

request = container.REQUEST\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
module_portal_type_value = portal_types.newContent(id=module_portal_type, portal_type=\'Base Type\')\n
# Set icon and allowed content types\n
module_portal_type_value.edit(\n
  type_factory_method_id=\'addFolder\',\n
  type_icon=\'folder_icon.gif\',\n
  type_filter_content_type=1,\n
  type_allowed_content_type_list=(object_portal_type_id,),\n
  type_base_category_list=(\'business_application\',),\n
  type_group=\'module\')\n
# initialize translation domains\n
module_portal_type_value.changeTranslations(\n
             properties=dict(title=\'erp5_ui\', short_title=\'erp5_ui\'))\n
\n
module_list_form_id = (\'%s_view%sList\' % (module_portal_type,\n
                        object_portal_type)).replace(\' \', \'\')\n
\n
module_portal_type_value.newContent(portal_type=\'Action Information\',\n
  reference="view",\n
  title="View",\n
  action="string:${object_url}/%s" % module_list_form_id,\n
  action_type="object_list")\n
\n
# Create the skin folder if does not exist yet\n
portal_skins_folder_name = portal_skins_folder\n
portal_skins = portal.portal_skins\n
if not portal_skins_folder_name in portal.portal_skins.objectIds():\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
factory = skin_folder.manage_addProduct[\'ERP5Form\']\n
\n
# Create a form for the module\n
factory.addERP5Form(module_list_form_id, title=module_title)\n
form = skin_folder[module_list_form_id]\n
default_groups = [\'bottom\', \'hidden\']\n
for group in default_groups:\n
  form.add_group(group)\n
\n
# XXX this is too low level, but we don\'t have an API available from restricted\n
# environment. Afterall, this script should not use restricted environment\n
form.manage_settings(\n
    dict(field_title=form.title,\n
         field_name=form.name,\n
         field_description=form.description,\n
         field_action=\'Base_doSelect\',\n
         field_update_action=form.update_action,\n
         field_update_action_title=form.update_action_title,\n
         field_enctype=form.enctype,\n
         field_encoding=form.encoding,\n
         field_stored_encoding=form.stored_encoding,\n
         field_unicode_mode=form.unicode_mode,\n
         field_method=form.method,\n
         field_row_length=str(form.row_length),\n
         field_pt=\'form_list\',\n
         field_edit_order=[]))\n
\n
form.manage_addField(\n
         id=\'listbox\',\n
         fieldname=\'ProxyField\',\n
         title=\'\')\n
form.move_field_group((\'listbox\',), \'left\', \'bottom\')\n
\n
form.listbox.manage_edit_xmlrpc(\n
    dict(form_id=\'Base_viewFieldLibrary\',\n
         field_id=\'my_list_mode_listbox\'))\n
\n
form.listbox.manage_edit_surcharged_xmlrpc(\n
    dict(selection_name=(\'_\'.join(module_portal_type.split())).lower() + \'_selection\',\n
         title=module_title,\n
         portal_type=[(object_portal_type, object_portal_type), ], ))\n
\n
\n
# Create a form for the document\n
form_view_id = object_portal_type_id.replace(\' \',\'\') + \'_view\'\n
factory.addERP5Form(form_view_id, title=object_title)\n
form = skin_folder[form_view_id]\n
form.rename_group(\'Default\', \'left\')\n
default_groups = [\'right\', \'center\', \'bottom\', \'hidden\']\n
for group in default_groups:\n
  form.add_group(group)\n
\n
form.manage_settings(\n
    dict(field_title=form.title,\n
         field_name=form.name,\n
         field_description=form.description,\n
         field_action=\'Base_edit\',\n
         field_update_action=form.update_action,\n
         field_update_action_title=form.update_action_title,\n
         field_enctype=form.enctype,\n
         field_encoding=form.encoding,\n
         field_stored_encoding=form.stored_encoding,\n
         field_unicode_mode=form.unicode_mode,\n
         field_method=form.method,\n
         field_row_length=str(form.row_length),\n
         field_pt=\'form_view\',\n
         field_edit_order=[]))\n
\n
form.manage_addField(\n
         id=\'my_title\',\n
         fieldname=\'StringField\',\n
         title=\'Title\')\n
\n
\n
# Then add the portal_type corresponding to the new object\n
object_portal_type_value = portal_types.newContent(id=object_portal_type_id, portal_type=\'Base Type\', type_factory_method_id=\'addXMLObject\')\n
\n
# Chain to edit_workflow\n
portal.portal_workflow.setChainForPortalTypes([object_portal_type_id],\n
                                              \'edit_workflow\')\n
\n
# Set default actions\n
object_portal_type_value.newContent(portal_type=\'Action Information\',\n
  reference="view",\n
  title="View",\n
  action="string:${object_url}/%s" % form_view_id,\n
  action_type="object_view")\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
# Clear caches so that module is immediatly visible\n
portal.changeSkin(None)\n
portal.portal_caches.clearAllCache()\n
\n
if not selection_index:\n
  redirect_url = \'%s/%s?%s\' % ( context.absolute_url()\n
                              , form_id\n
                              , \'portal_status_message=Module+Created.\'\n
                              )\n
else:\n
  redirect_url = \'%s/%s?selection_index=%s&selection_name=%s&%s\' % ( context.absolute_url()\n
                          , form_id\n
                          , selection_index\n
                          , selection_name\n
                          , \'portal_status_message=Module+Created.\'\n
                          )\n
\n
\n
request[ \'RESPONSE\' ].redirect( redirect_url )\n


]]></string> </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, selection_index=0, selection_name=\'\', form_id=\'\'</string> </value>
        </item>
        <item>
            <key> <string>id</string> </key>
            <value> <string>ERP5Site_createModule</string> </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
