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

from ZTUtils import make_query\n
from Products.PythonScripts.standard import url_quote\n
\n
REQUEST = container.REQUEST\n
RESPONSE = REQUEST.RESPONSE\n
selection_name = kw[\'list_selection_name\']\n
\n
uids = context.portal_selections.getSelectionCheckedUidsFor(selection_name)\n
\n
if len(uids) == 0:\n
  return context.REQUEST.RESPONSE.redirect(\n
           \'%s/TemplateTool_viewInstallRepositoryBusinessTemplateListDialog?\'\n
           \'portal_status_message=%s\' % ( context.absolute_url(),\n
                               url_quote(\'No Business Template Selected.\')))\n
\n
# Initilization\n
id_list = []\n
portal_status_message = \'\'\n
current_uid_list=[]\n
for uid in uids:\n
  current_uid_list.append(uid)\n
  repository, id = context.decodeRepositoryBusinessTemplateUid(uid)\n
  id_list.append(id)\n
\n
# Check for missing dependencies\n
for uid in uids:\n
  repository, id = context.decodeRepositoryBusinessTemplateUid(uid)\n
  dependency_list = context.getDependencyList((repository, id));\n
  for dep_repository, dep_id in dependency_list:\n
    if dep_id not in id_list:\n
      id_list.append(dep_id)\n
      if dep_repository != \'meta\':\n
        portal_status_message+=\'\\\'%s\\\' added because \\\'%s\\\' depends on it.<br/>\'%(dep_id.replace(\'.bt5\', \'\'), id.replace(\'.bt5\', \'\'))\n
        current_uid_list.append(context.encodeRepositoryBusinessTemplateUid(dep_repository, dep_id))\n
      else:\n
        provider_list = context.getProviderList(dep_id)\n
        provider_installed = False\n
        for provider in provider_list:\n
          if provider+\'.bt5\' in id_list:\n
            provider_installed = True\n
            break\n
        if not provider_installed:\n
          portal_status_message+=\'\\\'%s\\\' requires you to select one of the following business templates: %s\'%(id.replace(\'.bt5\', \'\'), provider_list)\n
\n
# If somes dependencies were missing\n
# we call the dialog again with the\n
# new bts selected\n
if portal_status_message != \'\' :\n
  #context.portal_selections.setSelectionCheckedUidsFor(REQUEST.get(\'selection_name\'), current_uid_list)\n
  context.portal_selections.setSelectionCheckedUidsFor(\'template_tool_install_selection\', current_uid_list)\n
  return context.REQUEST.RESPONSE.redirect(\'%s/TemplateTool_viewInstallRepositoryBusinessTemplateListDialog?portal_status_message=%s\'%(context.absolute_url(), url_quote(portal_status_message)))\n
\n
# order uids according to dependencies before processing\n
tuple_list = []\n
for uid in uids:\n
  tuple_list.append(context.decodeRepositoryBusinessTemplateUid(uid))\n
tuple_list = context.sortBusinessTemplateList(tuple_list)\n
\n
\n
bt_list = []\n
for repository, id in tuple_list:\n
  bt = context.download(\'/\'.join([repository, id]))\n
  bt_list.append(bt.getId())\n
\n
RESPONSE.redirect(\'%s/TemplateTool_viewMultiInstallationDialog?%s&form_id=BusinessTemplate_installationChoice\' %(context.absolute_url(), make_query({\'bt_list\' : bt_list})))\n
#return context.ERP5XhtmlStyle_redirect(\'%s/TemplateTool_viewMultiInstallationDialog\' % (context.absolute_url(), ), {\'bt_list\' : bt_list})\n


]]></string> </value>
        </item>
        <item>
            <key> <string>_code</string> </key>
            <value>
              <none/>
            </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string>**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>0</int> </value>
                    </item>
                    <item>
                        <key> <string>co_varnames</string> </key>
                        <value>
                          <tuple>
                            <string>kw</string>
                            <string>ZTUtils</string>
                            <string>make_query</string>
                            <string>Products.PythonScripts.standard</string>
                            <string>url_quote</string>
                            <string>_getattr_</string>
                            <string>container</string>
                            <string>REQUEST</string>
                            <string>RESPONSE</string>
                            <string>_getitem_</string>
                            <string>selection_name</string>
                            <string>context</string>
                            <string>uids</string>
                            <string>len</string>
                            <string>id_list</string>
                            <string>portal_status_message</string>
                            <string>current_uid_list</string>
                            <string>_getiter_</string>
                            <string>uid</string>
                            <string>repository</string>
                            <string>id</string>
                            <string>dependency_list</string>
                            <string>dep_repository</string>
                            <string>dep_id</string>
                            <string>_inplacevar_</string>
                            <string>provider_list</string>
                            <string>False</string>
                            <string>provider_installed</string>
                            <string>provider</string>
                            <string>True</string>
                            <string>tuple_list</string>
                            <string>bt_list</string>
                            <string>bt</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>TemplateTool_installRepositoryBusinessTemplateList</string> </value>
        </item>
        <item>
            <key> <string>warnings</string> </key>
            <value>
              <tuple/>
            </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
