[Zope-CMF] Portal_actions question

Paul Winkler pw_lists@slinkp.com
Thu, 29 Aug 2002 11:16:00 -0700


On Thu, Aug 29, 2002 at 01:48:38PM -0400, Hariharan Gopalan wrote:
> Condition - python:test(member and member.hasRole(Staff))

There is no object called Staff, unless you've created one...
role names are strings.

try  this:

python:test(member and member.has_role('Staff'))

Why has_role and not hasRole? Because of this note in the
source code for AccessControl/user.py:

       """hasRole is an alias for 'allowed' and has been deprecated.
        
        Code still using this method should convert to either 'has_role' or
        'allowed', depending on the intended behaviour.

        """

If you check your logs, you might see deprecation warnings when hasRole is 
called. If you're curious, here's the method signatures for 
has_role and allowed:

    def allowed(self, object, object_roles=None):
        """Check whether the user has access to object. The user must
           have one of the roles in object_roles to allow access."""


    def has_role(self, roles, object=None):
        """Check to see if a user has a given role or roles."""





--

Paul Winkler
"Welcome to Muppet Labs, where the future is made - today!"