Commit af791fc7 authored by Aurel's avatar Aurel

simplify the code for the install of skins layers


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4655 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9ed6634c
......@@ -885,45 +885,9 @@ class SkinTemplateItem(ObjectTemplateItem):
ObjectTemplateItem.__init__(self, id_list, tool_id=tool_id, **kw)
def install(self, context, trashbin, **kw):
ObjectTemplateItem.install(self, context, trashbin, **kw)
update_dict = kw.get('object_to_update')
force = kw.get('force')
if (getattr(self, 'template_format_version', 0)) == 1:
ObjectTemplateItem.install(self, context, trashbin, **kw)
p = context.getPortalObject()
ps = p.portal_skins
for skin_name, selection in ps.getSkinPaths():
new_selection = []
selection = selection.split(',')
for relative_url in self._objects.keys():
if update_dict.has_key(relative_url) or force:
if not force:
action = update_dict[relative_url]
if action == 'nothing':
continue
object_path = relative_url.split('/')
if len(object_path) > 2:
continue # not a skin folder
object = self._objects[relative_url]
skin_id = object_path[1]
if hasattr(aq_base(object), 'getProperty'):
selection_list = object.getProperty('business_template_registered_skin_selections', None)
else:
continue
if selection_list is None or skin_name in selection_list:
if skin_id not in selection and skin_id not in new_selection:
new_selection.append(skin_id)
new_selection.extend(selection)
# sort the layer according to skin priorities
new_selection.sort(lambda a, b : cmp( # separate functions here
b in ps.objectIds() and ps[b].getProperty(
'business_template_skin_layer_priority', 0) or 0,
a in ps.objectIds() and ps[a].getProperty(
'business_template_skin_layer_priority', 0) or 0))
ps.manage_skinLayers(skinpath = tuple(new_selection), skinname = skin_name, add_skin = 1)
# Make sure that skin data is up-to-date (see CMFCore/Skinnable.py).
p.changeSkin(None)
else:
ObjectTemplateItem.install(self, context, trashbin, **kw)
p = context.getPortalObject()
# It is necessary to make sure that the sql connections in Z SQL Methods are valid.
sql_connection_list = p.objectIds(spec=('Z MySQL Database Connection',))
......@@ -938,6 +902,13 @@ class SkinTemplateItem(ObjectTemplateItem):
new_selection = []
selection = selection.split(',')
for relative_url in self._archive.keys():
if (getattr(self, 'template_format_version', 0)) == 1:
if update_dict.has_key(relative_url) or force:
if not force:
if update_dict[relative_url] == 'nothing':
continue
object = self._objects[relative_url]
else:
object = self._archive[relative_url]
skin_id = relative_url.split('/')[-1]
selection_list = object.getProperty('business_template_registered_skin_selections', None)
......
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