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): ...@@ -33,25 +33,22 @@ def mergedLocalRoles(object):
merged = {} merged = {}
object = getattr(object, 'aq_inner', object) object = getattr(object, 'aq_inner', object)
while 1: while 1:
if hasattr(object, '__ac_local_roles__'): if getattr(object, '__ac_local_roles__', None) is not None:
roles = object.__ac_local_roles__ or {} roles = object.__ac_local_roles__ or {}
if callable(roles): roles = roles() if callable(roles): roles = roles()
for k, v in roles.items(): for k, v in roles.iteritems():
if merged.has_key(k): merged.setdefault(k, []).extend(v)
merged[k] = merged[k] + v
else:
merged[k] = v
# block acquisition # block acquisition
if hasattr(object, '_getAcquireLocalRoles'): if getattr(object, '_getAcquireLocalRoles', None) is not None:
if not object._getAcquireLocalRoles(): if not object._getAcquireLocalRoles() is not None:
break break
if hasattr(object, 'aq_parent'): if getattr(object, 'aq_parent', None) is not None:
object=object.aq_parent object = object.aq_parent
object=getattr(object, 'aq_inner', object) object = getattr(object, 'aq_inner', object)
continue continue
if hasattr(object, 'im_self'): if getattr(object, 'im_self', None) is not None:
object=object.im_self object = object.im_self
object=getattr(object, 'aq_inner', object) object = getattr(object, 'aq_inner', object)
continue continue
break 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