[Zope-PAS] Multiple principals with the same ID

Sidnei da Silva sidnei at enfoldsystems.com
Thu Dec 1 11:46:41 EST 2005


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.

Is anyone against removing that assertion?

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

-- 
Sidnei da Silva
Enfold Systems, LLC.
http://enfoldsystems.com


More information about the Zope-PAS mailing list