[Zope3-Users] Read out permissions

Florian Lindner mailinglists at xgm.de
Tue Jan 4 17:08:44 EST 2005


Am Dienstag, 4. Januar 2005 13:19 schrieben Sie:
> On Monday 03 January 2005 10:22, Florian Lindner wrote:
> > how can I use python code to read out the permission from a IInterface
> > derived object?
>
> I really do not understand what you are asking? I think what you want is
> the Checker that was created by providing a particular interface and
> permission.
>
> The zope.security.checker module has some nice API methods for this:
>
> selectChecker(iobject)
> getCheckerForInstancesOf(class_)
>
> I am not sure whether there are higher level APIs, but this is the one I
> found immediately. You can also look at the API doctool code, since it
> provides such information as well.

Ok, here is what I want:

I have an object:

class IEvent(Interface):

Now I want to traverse through all subdirs and get all the instances of this 
class for which the current users has the zope.View permission.

My untested implementation:

        for folder in context.items():
     for itm in folder.items():
            chk = getCheckerForInstancesOf(IEvent)
            if chk.check_getattr(itm, "name"):
                assigned.append(itm)

name is a attribute of IEvent.

You got my idea?  ;-)

Florian


More information about the Zope3-users mailing list