Commit 3f07af10 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Upon Business Path Item installation, update Local Roles of objects whose...

Upon Business Path Item installation, update Local Roles of objects whose Portal Types defines Roles.

Before, Local Roles were not updated upon Path Item installation, thus leading
to security issues (such as Trade Model Line). This avoids ugly hacks in
Upgrader and in tests as well.
parent 5f3f2257
...@@ -73,7 +73,7 @@ customImporters={ ...@@ -73,7 +73,7 @@ customImporters={
XMLExportImport.magic: importXML, XMLExportImport.magic: importXML,
} }
from zLOG import LOG, WARNING from zLOG import LOG, WARNING, INFO
from warnings import warn from warnings import warn
from gzip import GzipFile from gzip import GzipFile
from lxml.etree import parse from lxml.etree import parse
...@@ -1400,6 +1400,40 @@ class PathTemplateItem(ObjectTemplateItem): ...@@ -1400,6 +1400,40 @@ class PathTemplateItem(ObjectTemplateItem):
self._objects[relative_url] = obj self._objects[relative_url] = obj
obj.wl_clearLocks() obj.wl_clearLocks()
def install(self, context, *args, **kw):
super(PathTemplateItem, self).install(context, *args, **kw)
p = context.getPortalObject()
portal_type_role_list_len_dict = {}
for path in self._objects:
obj = p.unrestrictedTraverse(path)
try:
portal_type = obj.getPortalType()
except Exception, e:
LOG("BusinessTemplate", WARNING,
"Could not update Local Roles as Portal Type for '%s' is not "
"available (%s)" % (obj, e))
continue
if portal_type not in p.portal_types:
LOG("BusinessTemplate", WARNING,
"Could not update Local Roles as Portal Type '%s' could not "
"be found" % portal_type)
continue
if portal_type not in portal_type_role_list_len_dict:
portal_type_role_list_len_dict[portal_type] = \
len(p.portal_types[portal_type].getRoleInformationList())
if portal_type_role_list_len_dict[portal_type]:
p.portal_types[portal_type].updateLocalRolesOnDocument(obj)
LOG("BusinessTemplate", INFO,
"Updated Local Roles for '%s' (%s)" % (portal_type,
obj.getRelativeUrl()))
class ToolTemplateItem(PathTemplateItem): class ToolTemplateItem(PathTemplateItem):
"""This class is used only for making a distinction between other objects """This class is used only for making a distinction between other objects
and tools, because tools may not be backed up.""" and tools, because tools may not be backed up."""
......
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