[Zope-CVS] CVS: Products/PluggableAuthService/plugins -
ZODBRoleManager.py:1.4
Zachery Bir
zbir at urbanape.com
Mon Aug 30 11:27:52 EDT 2004
Update of /cvs-repository/Products/PluggableAuthService/plugins
In directory cvs.zope.org:/tmp/cvs-serv19230
Modified Files:
ZODBRoleManager.py
Log Message:
- Don't include 'Anonymous' and 'Authenticated' roles when adding a
ZODBRoleManager.
- Provide for *some* handle on principals that were assigned, but
are no longer found by PAS
=== Products/PluggableAuthService/plugins/ZODBRoleManager.py 1.3 => 1.4 ===
--- Products/PluggableAuthService/plugins/ZODBRoleManager.py:1.3 Thu Aug 12 11:15:54 2004
+++ Products/PluggableAuthService/plugins/ZODBRoleManager.py Mon Aug 30 11:27:52 2004
@@ -79,7 +79,8 @@
role_holder = aq_parent( aq_inner( container ) )
for role in getattr( role_holder, '__ac_roles__', () ):
try:
- self.addRole( role )
+ if role not in ('Anonymous', 'Authenticated'):
+ self.addRole( role )
except KeyError:
pass
@@ -129,14 +130,14 @@
e_url = '%s/manage_roles' % self.getId()
p_qs = 'role_id=%s' % role_id
m_qs = 'role_id=%s&assign=1' % role_id
-
+
info = {}
info.update( self._roles[ role_id ] )
-
+
info[ 'pluginid' ] = plugin_id
info[ 'properties_url' ] = '%s?%s' % (e_url, p_qs)
info[ 'members_url' ] = '%s?%s' % (e_url, m_qs)
-
+
if not role_filter or role_filter( info ):
role_info.append( info )
@@ -240,7 +241,7 @@
if ( role_id not in self._principal_roles.get( id, () )
and role_id != id ):
result.append( ( id, title ) )
-
+
return result
security.declareProtected( ManageUsers, 'listAssignedPrincipals' )
@@ -252,13 +253,17 @@
for k, v in self._principal_roles.items():
if role_id in v:
- # should be one and only one mapping to 'k'
+ # should be at most one and only one mapping to 'k'
parent = aq_parent( self )
info = parent.searchPrincipals( id=k, exact_match=True )
- assert( len( info ) == 1 )
- result.append( ( k, info[0].get( 'title', k ) ) )
-
+ assert( len( info ) in ( 0, 1 ) )
+ if len( info ) == 0:
+ title = '<%s: not found>' % k
+ else:
+ title = info[0].get( 'title', k )
+ result.append( ( k, title ) )
+
return result
security.declareProtected( ManageUsers, 'assignRoleToPrincipal' )
@@ -373,7 +378,7 @@
message = 'no+roles+selected'
else:
-
+
for role_id in role_ids:
self.removeRole( role_id )
@@ -418,7 +423,7 @@
""" Remove a role from one or more principals via the ZMI.
"""
removed = []
-
+
for principal_id in principal_ids:
if self.removeRoleFromPrincipal( role_id, principal_id ):
removed.append( principal_id )
More information about the Zope-CVS
mailing list