Logo Search packages:      
Sourcecode: zope-pas version File versions  Download package

def PluggableAuthService-1.4::PropertiedUser::PropertiedUser::getRolesInContext (   self,
  object 
)

Return the list of roles assigned to the user.

o Include local roles assigned in context of the passed-in object.

o Include *both* local roles assigned directly to us *and* those
  assigned to our groups.

o Ripped off from AccessControl.User.BasicUser, which provides
  no other extension mechanism. :(

Definition at line 85 of file PropertiedUser.py.

00085                                          :

        """ Return the list of roles assigned to the user.

        o Include local roles assigned in context of the passed-in object.

        o Include *both* local roles assigned directly to us *and* those
          assigned to our groups.

        o Ripped off from AccessControl.User.BasicUser, which provides
          no other extension mechanism. :(
        """
        user_id = self.getId()
        # [ x.getId() for x in self.getGroups() ]
        group_ids = self.getGroups()

        principal_ids = list( group_ids )
        principal_ids.insert( 0, user_id )

        local ={} 
        object = aq_inner( object )

        while 1:

            local_roles = getattr( object, '__ac_local_roles__', None )

            if local_roles:

                if callable( local_roles ):
                    local_roles = local_roles()

                dict = local_roles or {}

                for principal_id in principal_ids:
                    for role in dict.get( principal_id, [] ):
                        local[ role ] = 1

            inner = aq_inner( object )
            parent = aq_parent( inner )

            if parent is not None:
                object = parent
                continue

            new = getattr( object, 'im_self', None )

            if new is not None:

                object = aq_inner( new )
                continue

            break

        return list( self.getRoles() ) + local.keys()

    def allowed( self, object, object_roles=None ):


Generated by  Doxygen 1.6.0   Back to index