Commit 7bdc997a authored by Jim Fulton's avatar Jim Fulton

Changed signature of hasRole to accept instance where role came from.

parent 47498241
"""Access control package""" """Access control package"""
__version__='$Revision: 1.30 $'[11:-2] __version__='$Revision: 1.31 $'[11:-2]
from PersistentMapping import PersistentMapping from PersistentMapping import PersistentMapping
...@@ -25,7 +25,7 @@ class User(Implicit, Persistent): ...@@ -25,7 +25,7 @@ class User(Implicit, Persistent):
def authenticate(self, password): def authenticate(self, password):
return password==self.__ return password==self.__
def hasRole(self,roles=None): def hasRole(self,inst,roles=None):
if roles is None: if roles is None:
return 1 return 1
for role in roles: for role in roles:
......
"""Document object""" """Document object"""
__version__='$Revision: 1.37 $'[11:-2] __version__='$Revision: 1.38 $'[11:-2]
from Globals import HTML, HTMLFile, MessageDialog from Globals import HTML, HTMLFile, MessageDialog
from string import join,split,strip,rfind,atoi from string import join,split,strip,rfind,atoi
...@@ -61,14 +61,16 @@ class Document(HTML, Explicit, RoleManager, Item_w__name__): ...@@ -61,14 +61,16 @@ class Document(HTML, Explicit, RoleManager, Item_w__name__):
elif inst is parent: elif inst is parent:
return 1 return 1
else: else:
if str(name)[:6]=='manage': return 0 # if str(name)[:6]=='manage': return 0
if hasattr(parent,'__roles__'): roles=parent.__roles__ if hasattr(parent,'__roles__'):
roles=parent.__roles__
elif hasattr(parent, 'aq_acquire'): elif hasattr(parent, 'aq_acquire'):
try: roles=parent.aq_acquire('__roles__') try: roles=parent.aq_acquire('__roles__')
except AttributeError: return 0 except AttributeError: return 0
else: return 0 else: return 0
value=parent
if roles is None: return 1 if roles is None: return 1
try: return md.AUTHENTICATED_USER.hasRole(roles) try: return md.AUTHENTICATED_USER.hasRole(value, roles)
except AttributeError: return 0 except AttributeError: return 0
manage_editForm=HTMLFile('documentEdit', globals()) manage_editForm=HTMLFile('documentEdit', globals())
......
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