[Zope] skip_unauthorized

Jim Washington jwashin@vt.edu
Wed, 16 Oct 2002 15:58:05 -0400


Jacob Behm wrote:

>I've used skip_unauthorized with objectValues in a DTML method to hide
>folders that a user is not authorized to see and that works great.  But
>how do I pass that operator in a python script?  objectValues only takes
>one argument, that is, object type.
>
>Anybody know?
>  
>
Hi, Jacob

Here'a a snippet of something I have used...

from AccessControl import getSecurityManager

sm = getSecurityManager()

user = sm.getUser()

thelist = context.objectValues()

for item in thelist:

    if user.has_permission('View',item):

      #do something, they can view
    else:
      #do something else, they cannot view


-- Jim Washington