Commit 8e001351 authored by Nicolas Delaby's avatar Nicolas Delaby

Use getattr instead of hasattr; reindent code

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21007 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 6cf8c934
......@@ -33,25 +33,22 @@ def mergedLocalRoles(object):
merged = {}
object = getattr(object, 'aq_inner', object)
while 1:
if hasattr(object, '__ac_local_roles__'):
if getattr(object, '__ac_local_roles__', None) is not None:
roles = object.__ac_local_roles__ or {}
if callable(roles): roles = roles()
for k, v in roles.items():
if merged.has_key(k):
merged[k] = merged[k] + v
else:
merged[k] = v
for k, v in roles.iteritems():
merged.setdefault(k, []).extend(v)
# block acquisition
if hasattr(object, '_getAcquireLocalRoles'):
if not object._getAcquireLocalRoles():
if getattr(object, '_getAcquireLocalRoles', None) is not None:
if not object._getAcquireLocalRoles() is not None:
break
if hasattr(object, 'aq_parent'):
object=object.aq_parent
object=getattr(object, 'aq_inner', object)
if getattr(object, 'aq_parent', None) is not None:
object = object.aq_parent
object = getattr(object, 'aq_inner', object)
continue
if hasattr(object, 'im_self'):
object=object.im_self
object=getattr(object, 'aq_inner', object)
if getattr(object, 'im_self', None) is not None:
object = object.im_self
object = getattr(object, 'aq_inner', object)
continue
break
......
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