[Zope-PAS] Re: Multiple principals with the same ID

Tres Seaver tseaver at palladion.com
Thu Dec 1 12:33:47 EST 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Sidnei da Silva wrote:

> There is an assertion in ZODBRoleManager, in the
> listAssignedPrincipals method that makes it bomb when there's more
> than one principal returned from searchPrincipals.
> 
> Now, while it doesn't make much sense to have principals with the same
> id being returned by different plugins, that might be just the wrong
> place to enforce this.

We aren't "enforcing" anything:  the plugin can't fulfill its own
contract (in this case, to return a list of (id, title) tuples) if the
user has screwed up by configuring the other plugins that way.

> Is anyone against removing that assertion?

- -1.  Asserts only affect debug mode, anyway, which means that they help
find problems.

> Reproducing the method below for the lazy:
> 
>     def listAssignedPrincipals( self, role_id ):
> 
>         """ Return a list of principal IDs to whom a role is assigned.
>         """
>         result = []
> 
>         for k, v in self._principal_roles.items():
>             if role_id in v:
>                 # 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 ) 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



Tres.
- --
===================================================================
Tres Seaver          +1 202-558-7113          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDjzP7+gerLs4ltQ4RAiSZAJ9yGZEUiVQYRLzLYPZCGbqTDB6mxQCgqn26
/Qxv1FJQyfTkko2lt9qX0og=
=QhgK
-----END PGP SIGNATURE-----



More information about the Zope-PAS mailing list