[Zope3-Users] Check permissions

Thierry FLORAC tflorac at ulthar.net
Fri Mar 17 13:21:02 EST 2006


  Hi,

I think that you can also use something like this :

        from zope.security.management import getInteraction
        
        def checkPermission(object, permission='zope.ManageContent'):
            interaction = getInteraction()
            return interaction.checkPermission(permission, object)

I don't know what's the difference between the two methods, and so I
don't if one of them is better than the other one...

  Thierry


On Fri, 2006-03-17 at 13:34 +0000, Rupert Redington wrote:
> from zope.security.management import checkPermission
> 
> if checkPermission('zope.ManageContent', self.context):
>     """ ... """
> 
> Cheers,
> 
> Rupert
> 
> Frank Burkhardt wrote:
> > Hi,
> > 
> > how can I test, if the current principal (e.g. by being member in a special
> > group) has a given permission on a given content object?
> > 
> > Maybe something like this:
> > 
> >  if 'zope.ManageContent' in self.context.permissions():
> >     """..."""
> > 
> > This should include all permission defined in ZCML *and* all permission
> > granted in ZMI.
> > 
> > Thank you for all hints.
> > 
> > Regards,
> > 
> > Frank




-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



More information about the Zope3-users mailing list