Commit 5cd2ec1b authored by Christophe Dumez's avatar Christophe Dumez

2006-07-31 Chris

* Added dependency handling support for business templates

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@8932 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent f2cd1957
......@@ -71,6 +71,9 @@
<value> <string>from Products.ERP5Type.Document import newTempBase\n
from Products.ERP5Type.Cache import CachingMethod\n
\n
#Check dependencies, raise exception if a dependency is missing\n
context.checkDependencies()\n
\n
def getModifiedObjectList(context):\n
result = context.preinstall()\n
context.log(\'getModifiedObjectList cache filled\',\'\')\n
......@@ -161,10 +164,10 @@ return object_list\n
<string>newTempBase</string>
<string>Products.ERP5Type.Cache</string>
<string>CachingMethod</string>
<string>getModifiedObjectList</string>
<string>_getattr_</string>
<string>context</string>
<string>getModifiedObjectList</string>
<string>modified_object_list</string>
<string>_getattr_</string>
<string>keys</string>
<string>no_backup_list</string>
<string>i</string>
......
......@@ -97,7 +97,7 @@ for bt in bt_objects.keys():\n
modified_object_list = bt_objects[bt][1] \n
bt_title = bt_objects[bt][0]\n
keys = modified_object_list.keys()\n
keys.sort()\n
#keys.sort()\n
i = 0\n
for object_id in keys: \n
object_state, object_class = modified_object_list[object_id]\n
......
......@@ -70,6 +70,7 @@
<key> <string>_body</string> </key>
<value> <string>listbox = kw.get(\'listbox\', ())\n
\n
bt_id_list = getattr(context.REQUEST, \'bt_list\', ())\n
bt_dict = {}\n
object_to_update = {}\n
for item in listbox:\n
......@@ -87,6 +88,12 @@ for bt_id in bt_dict.keys():\n
bt.install(force=0, object_to_update=object_list)\n
bt_title_list.append(bt.getTitle())\n
\n
for id in bt_id_list:\n
if id not in bt_dict.keys():\n
bt = context.portal_templates[id]\n
bt.install(force=0, object_to_update=[])\n
bt_title_list.append(bt.getTitle())\n
\n
\n
REQUEST = container.REQUEST\n
RESPONSE = REQUEST.RESPONSE\n
......@@ -143,6 +150,9 @@ return RESPONSE.redirect("%s?portal_status_message=Business+Template+%s+installe
<string>kw</string>
<string>_getattr_</string>
<string>listbox</string>
<string>getattr</string>
<string>context</string>
<string>bt_id_list</string>
<string>bt_dict</string>
<string>object_to_update</string>
<string>_getiter_</string>
......@@ -153,8 +163,8 @@ return RESPONSE.redirect("%s?portal_status_message=Business+Template+%s+installe
<string>_write_</string>
<string>bt_title_list</string>
<string>object_list</string>
<string>context</string>
<string>bt</string>
<string>id</string>
<string>container</string>
<string>REQUEST</string>
<string>RESPONSE</string>
......
......@@ -76,20 +76,60 @@ REQUEST = container.REQUEST\n
RESPONSE = REQUEST.RESPONSE\n
\n
uids = getattr(REQUEST, \'uids\', ())\n
ret_url = \'/\'.join([context.absolute_url(), REQUEST.get(\'form_id\', \'view\')])\n
\n
#return repr(len(uids))\n
if len(uids) == 0:\n
RESPONSE.redirect("%s?portal_status_message=No+Business+Template+Specified" % ret_url)\n
return\n
return context.REQUEST.RESPONSE.redirect(\'%s/TemplateTool_viewInstallRepositoryBusinessTemplateListDialog?portal_status_message=%s\'%(context.absolute_url(), context.urlQuote(\'No Business Template specified.\')))\n
\n
bt_list = []\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(), context.urlQuote(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
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>
......@@ -149,14 +189,25 @@ RESPONSE.redirect(\'%s/TemplateTool_viewMultiInstallationDialog?%s&form_id=Busin
<string>RESPONSE</string>
<string>getattr</string>
<string>uids</string>
<string>context</string>
<string>ret_url</string>
<string>len</string>
<string>bt_list</string>
<string>context</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>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>
......
1.0rc8
\ No newline at end of file
1.0rc9
\ 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