durusmail: qp: permissions and root object
permissions and root object
2006-01-24
2006-01-24
permissions and root object
mario ruggier
2006-01-24
hi,

qp uses the value of True to indicate "the root object", as the granter
of a permission to a user, which I take it to mean that if the granter
is True then the user has this permission domain-wide.

The qp.lib.user.User.is_granted() method does not do it this way though:

     def is_granted(self, permission, other=None):
         """(permission:basestring, other:Persistent=None) -> bool
         Does this user have the `permission` granted from the `other`?
         If no value is provided for other, the root object is used as
         the `other`.
         """
         if other is None:
             return self.permissions.is_granted(
                 permission, get_publisher().get_root())
         else:
             return self.permissions.is_granted(permission, other)

but unless i misunderstand something, i suspect this is simply a
remnant of some previous idea you were working with. I take it that
this method should simply be:

     def is_granted(self, permission, other=True):
         """(permission:basestring, other:either(Persistent,True)=True)
-> bool
         Does this user have the `permission` granted from the `other`?
         """
         return self.permissions.is_granted(permission, other)

mario

reply