[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/AuthenticationService - User.py:1.3
Stephan Richter
srichter@cbu.edu
Sat, 13 Jul 2002 15:11:16 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/AuthenticationService
In directory cvs.zope.org:/tmp/cvs-serv11237/lib/python/Zope/App/OFS/Services/AuthenticationService
Modified Files:
User.py
Log Message:
Now the roles are saved using Annotations. Yeah! :)
=== Zope3/lib/python/Zope/App/OFS/Services/AuthenticationService/User.py 1.2 => 1.3 ===
$Id$
"""
from Persistence import Persistent
+from Zope.Proxy.ProxyIntrospection import removeAllProxies
from Zope.App.OFS.Annotation.IAttributeAnnotatable import IAttributeAnnotatable
+from Zope.App.OFS.Annotation.AttributeAnnotations import AttributeAnnotations
from Zope.App.OFS.Services.AuthenticationService.IUser import IUser
from Zope.App.Security.Grants.Global.PrincipalRoleManager import \
principalRoleManager
@@ -46,8 +48,9 @@
def getRoles(self):
'See Zope.App.OFS.Services.AuthenticationService.IUser.IReadUser'
- roles = principalRoleManager.getRolesForPrincipal(self.getId())
- roles = map(lambda r: r[0], roles)
+ annotations = AttributeAnnotations(self)
+ roles = annotations.get('roles', [])
+ roles = removeAllProxies(roles)
return roles
def validate(self, pw):
@@ -89,8 +92,8 @@
def setRoles(self, roles):
'See Zope.App.OFS.Services.AuthenticationService.IUser.IReadUser'
- id = self.getId()
- for role in roles:
- principalRoleManager.assignRoleToPrincipal(role, id)
+ annotations = AttributeAnnotations(self)
+ annotations['roles'] = roles
+
#
############################################################