Commit a59519ca authored by Nicolas Delaby's avatar Nicolas Delaby

Small code refactoring,

  * remove useless statements
  * naming convention compliancy



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33762 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e7b7f51c
...@@ -2091,21 +2091,20 @@ class PortalTypeAllowedContentTypeTemplateItem(BaseTemplateItem): ...@@ -2091,21 +2091,20 @@ class PortalTypeAllowedContentTypeTemplateItem(BaseTemplateItem):
else: else:
old_objects = {} old_objects = {}
for key in set(self._objects.keys()).union(set(old_objects.keys())): for key in set(self._objects.keys()).union(set(old_objects.keys())):
if update_dict.has_key(key) or force: if key in update_dict or force:
if not force: if not force:
action = update_dict[key] action = update_dict[key]
if action == 'nothing': if action == 'nothing':
continue continue
try: try:
portal_id = key.split('/')[-1] portal_id = key.split('/')[-1]
portal_type = pt._getOb(portal_id) portal_type = types_tool._getOb(portal_id)
except (AttributeError, KeyError): except (AttributeError, KeyError):
raise AttributeError, "Portal type '%s' not found while " \ raise AttributeError, "Portal type '%s' not found while " \
"installing %s" % (portal_id, self.getTitle()) "installing %s" % (portal_id, self.getTitle())
property_list = self._objects.get(key, []) property_list = self._objects.get(key, [])
old_property_list = old_objects.get(key, ()) old_property_list = old_objects.get(key, ())
object_property_list = getattr(portal_type, self.class_property, ()) object_property_list = getattr(portal_type, self.class_property, ())
if len(object_property_list) > 0:
# merge differences between portal types properties # merge differences between portal types properties
# for example: # for example:
# * current value : [A,B,C] # * current value : [A,B,C]
...@@ -2119,16 +2118,16 @@ class PortalTypeAllowedContentTypeTemplateItem(BaseTemplateItem): ...@@ -2119,16 +2118,16 @@ class PortalTypeAllowedContentTypeTemplateItem(BaseTemplateItem):
def uninstall(self, context, **kw): def uninstall(self, context, **kw):
object_path = kw.get('object_path', None) object_path = kw.get('object_path', None)
p = context.getPortalObject() portal = context.getPortalObject()
pt = p.unrestrictedTraverse('portal_types') types_tool = getToolByName(portal, 'portal_types')
if object_path is not None: if object_path is not None:
object_keys = [object_path] object_key_list = [object_path]
else: else:
object_keys = self._objects.keys() object_key_list = self._objects.keys()
for key in object_keys: for key in object_key_list:
try: try:
portal_id = key.split('/')[-1] portal_id = key.split('/')[-1]
portal_type = pt._getOb(portal_id) portal_type = types_tool._getOb(portal_id)
except (AttributeError, KeyError): except (AttributeError, KeyError):
LOG("portal types not found : ", 100, portal_id) LOG("portal types not found : ", 100, portal_id)
continue continue
......
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