Commit 9d44f7aa authored by 's avatar

Added has_role method, changed hasRole to allowed, leaving hasRole as an alias.

parent 53db5d28
"""Access control package"""
__version__='$Revision: 1.43 $'[11:-2]
__version__='$Revision: 1.44 $'[11:-2]
from PersistentMapping import PersistentMapping
......@@ -24,7 +24,7 @@ class User(Implicit, Persistent):
def authenticate(self, password):
return password==self.__
def hasRole(self,parent,roles=None):
def allowed(self,parent,roles=None):
obj=parent
obj_roles=roles
usr_roles=self.roles
......@@ -48,6 +48,17 @@ class User(Implicit, Persistent):
continue
return 0
hasRole=allowed
def has_role(self, roles):
if type(roles)==type('s'):
roles=[roles]
user_roles=self.roles
for role in roles:
if role in user_roles:
return 1
return 0
def __len__(self): return 1
def __str__(self): return self.name
__repr__=__str__
......
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