Commit 653fc5b7 authored by Julien Muchembled's avatar Julien Muchembled

Code style changes (based on Yoshinori's comments)

git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/portal_types@29284 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a41f5c7e
......@@ -1554,8 +1554,10 @@ class PortalTypeTemplateItem(ObjectTemplateItem):
for relative_url in self._archive.keys():
obj = p.unrestrictedTraverse(relative_url)
obj = obj._getCopy(context)
# obj is in ghost state and an attribute must be accessed
# so that obj.__dict__ does not return an empty dict
obj.meta_type
for attr in tuple(obj.__dict__):
for attr in obj.__dict__.keys():
if attr == '_property_domain_dict':
continue
if attr[0] == '_' or attr in ('allowed_content_types',
......
......@@ -1714,7 +1714,7 @@ class ERP5Generator(PortalGenerator):
tool = getToolByName(p, 'portal_types', None)
if tool is None:
return
for t in BusinessTemplate,:
for t in (BusinessTemplate, ):
t = t.factory_type_information
if not tool.hasObject(t['id']):
tool._setObject(t['id'], ERP5TypeInformation(uid=None, **t))
......@@ -1728,7 +1728,7 @@ class ERP5Generator(PortalGenerator):
return
if template_tool.getInstalledBusinessTemplate('erp5_core') is None:
bootstrap_dir = self.getBootstrapDirectory()
for bt in 'erp5_core', p.erp5_catalog_storage, 'erp5_xhtml_style':
for bt in ('erp5_core', p.erp5_catalog_storage, 'erp5_xhtml_style'):
if not bt:
continue
template = os.path.join(bootstrap_dir, bt)
......
......@@ -69,11 +69,11 @@ class ActionInformation(XMLObject):
category = self.getActionType() or ''
info = ec.vars
if (info['here'] is not None and
(category.startswith('object') or
category.startswith('workflow'))):
(category[:6] == 'object' or
category[:8] == 'workflow')):
context = info['here']
elif (info['folder'] is not None and
category.startswith('folder')):
category[:6] == 'folder'):
context = info['folder']
else:
context = info['portal']
......@@ -105,12 +105,14 @@ class ActionInformation(XMLObject):
if isinstance(value, basestring):
value = value and Expression(value) or None
self._baseSetAction(value)
def _setCondition(self, value):
"""Overridden setter for 'condition' to accept string and clean null values
"""
if isinstance(value, basestring):
value = value and Expression(value) or None
self._baseSetCondition(value)
def _setIcon(self, value):
"""Overridden setter for 'icon' to accept string and clean null values
"""
......@@ -123,11 +125,13 @@ class ActionInformation(XMLObject):
if getattr(aq_base(self), 'action', None) == '':
del self.action
return self._baseGetAction()
def getCondition(self):
"""Overridden getter for 'condition' to clean null values"""
if getattr(aq_base(self), 'condition', None) == '':
del self.condition
return self._baseGetCondition()
def getIcon(self):
"""Overridden getter for 'icon' to clean null values"""
if getattr(aq_base(self), 'icon', None) == '':
......@@ -138,10 +142,12 @@ class ActionInformation(XMLObject):
def getActionText(self):
"""Return the text of the action expression"""
return getattr(self.getAction(), 'text', None)
security.declareProtected(AccessContentsInformation, 'getConditionText')
def getConditionText(self):
"""Return the text of the condition expression"""
return getattr(self.getCondition(), 'text', None)
security.declareProtected(AccessContentsInformation, 'getIconText')
def getIconText(self):
"""Return the text of the icon expression"""
......
......@@ -457,7 +457,7 @@ class ERP5TypeInformation(XMLObject,
id = id + "d"
return factory_method(portal, id).propertyMap()
def edit(self, *args, **kw):
def _edit(self, *args, **kw):
"""
Method overload
......@@ -470,7 +470,7 @@ class ERP5TypeInformation(XMLObject,
"""
property_list = 'factory', 'property_sheet_list', 'base_category_list'
previous_state = [getattr(aq_base(self), x) for x in property_list]
result = XMLObject.edit(self, *args, **kw)
result = XMLObject._edit(self, *args, **kw)
if previous_state != [getattr(aq_base(self), x) for x in property_list]:
from Products.ERP5Type.Base import _aq_reset
_aq_reset()
......
......@@ -1113,7 +1113,7 @@ def createExpressionContext(object, portal=None):
if portal is None and object is not None:
portal = object.getPortalObject()
if object is None or aq_base(object) is None:
if object is None or getattr(object, 'aq_base', None) is None:
folder = portal
else:
folder = object
......
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