<?xml version="1.0"?>
<ZopeData>
  <record id="1" aka="AAAAAAAAAAE=">
    <pickle>
      <tuple>
        <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
        <tuple/>
      </tuple>
    </pickle>
    <pickle>
      <dictionary>
        <item>
            <key> <string>Python_magic</string> </key>
            <value>
              <none/>
            </value>
        </item>
        <item>
            <key> <string>Script_magic</string> </key>
            <value> <int>3</int> </value>
        </item>
        <item>
            <key> <string>__ac_local_roles__</string> </key>
            <value>
              <none/>
            </value>
        </item>
        <item>
            <key> <string>_bind_names</string> </key>
            <value>
              <object>
                <klass>
                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
                </klass>
                <tuple/>
                <state>
                  <dictionary>
                    <item>
                        <key> <string>_asgns</string> </key>
                        <value>
                          <dictionary>
                            <item>
                                <key> <string>name_container</string> </key>
                                <value> <string>container</string> </value>
                            </item>
                            <item>
                                <key> <string>name_context</string> </key>
                                <value> <string>context</string> </value>
                            </item>
                            <item>
                                <key> <string>name_m_self</string> </key>
                                <value> <string>script</string> </value>
                            </item>
                            <item>
                                <key> <string>name_subpath</string> </key>
                                <value> <string>traverse_subpath</string> </value>
                            </item>
                          </dictionary>
                        </value>
                    </item>
                  </dictionary>
                </state>
              </object>
            </value>
        </item>
        <item>
            <key> <string>_body</string> </key>
            <value> <string encoding="cdata"><![CDATA[

request = container.REQUEST\n
\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
portal_types.manage_addTypeInformation( \'ERP5 Type Information\'\n
                                       , typeinfo_name = \'ERP5Type: ERP5 Folder\'\n
                                       , id            = module_portal_type)\n
module_portal_type_value = portal_types[module_portal_type]\n
# Set icon and allowed content types\n
module_portal_type_value.manage_changeProperties(\n
               content_icon=\'folder_icon.gif\',\n
               filter_content_types=1,\n
               allowed_content_types=(object_portal_type_id, ),\n
               group_list=(\'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
action_list = module_portal_type_value.listActions()\n
module_portal_type_value.deleteActions(selections=range(0, len(action_list)))\n
module_portal_type_value.addAction( "view"\n
                                  , "View"\n
                                  , "string:${object_url}/%s" % module_list_form_id\n
                                  , ""\n
                                  , "View"\n
                                  , "object_list"\n
                                  , priority=1.0\n
                                  )\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_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_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
portal_types.manage_addTypeInformation(\'ERP5 Type Information\'\n
                                      , typeinfo_name = \'ERP5Type: XML Object (ERP5 XML Object)\'\n
                                      , id            = object_portal_type_id\n
                                      )\n
object_portal_type_value = portal_types[object_portal_type_id]\n
\n
# Chain to edit_workflow\n
portal.portal_workflow.setChainForPortalTypes([object_portal_type_id],\n
                                              \'edit_workflow\')\n
\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
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
\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
\n
request[ \'RESPONSE\' ].redirect( redirect_url )\n


]]></string> </value>
        </item>
        <item>
            <key> <string>_code</string> </key>
            <value>
              <none/>
            </value>
        </item>
        <item>
            <key> <string>_filepath</string> </key>
            <value>
              <none/>
            </value>
        </item>
        <item>
            <key> <string>_owner</string> </key>
            <value>
              <none/>
            </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string>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>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>9</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>selection_index</string>
                            <string>selection_name</string>
                            <string>form_id</string>
                            <string>_getattr_</string>
                            <string>container</string>
                            <string>request</string>
                            <string>context</string>
                            <string>portal</string>
                            <string>portal_types</string>
                            <string>object_portal_type_id</string>
                            <string>_getitem_</string>
                            <string>module_portal_type_value</string>
                            <string>dict</string>
                            <string>module_list_form_id</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>factory</string>
                            <string>form</string>
                            <string>default_groups</string>
                            <string>group</string>
                            <string>str</string>
                            <string>form_view_id</string>
                            <string>object_portal_type_value</string>
                            <string>module_object</string>
                            <string>None</string>
                            <string>redirect_url</string>
                          </tuple>
                        </value>
                    </item>
                  </dictionary>
                </state>
              </object>
            </value>
        </item>
        <item>
            <key> <string>func_defaults</string> </key>
            <value>
              <tuple>
                <int>0</int>
                <string></string>
                <string></string>
              </tuple>
            </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>
</ZopeData>
