AW: [Zope3-Users] How to check access on a view?

Roger Ineichen dev at projekt01.ch
Sun Feb 17 06:41:06 EST 2008


Hi Hermann

> Betreff: Re: [Zope3-Users] How to check access on a view?

[...]

> > Hi,
> > For a simple menu, I need to check if the current principal has 
> > permissions to access a view. I understand that I can use the 
> > canAccess()/canWrite() function on object attributes but 
> how could I 
> > do this for views?

import zope.security
zope.security.canAccess(myView, '__call__') should work.
Or if the view provides a render method, you can check
zope.security.canAccess(myView, 'render').

See zope.viewlet, there we use this pattern in the viewlet manager
zope.viewlet.manager line 85.

Regards
Roger Ineichen

> > Best Regards,
> > Hermann



More information about the Zope3-users mailing list