[Zope] Test for 'View' permission

J Cameron Cooper jccooper@jcameroncooper.com
Fri, 07 Mar 2003 19:25:59 -0600


>
> I have a Python script witch takes a list of Zope objects and returns 
> only the objects with 'View' permission for Anonymous users.
> The script is called by a Zope Manager.
> How do I do that ??

Do you mean you want to do that? 'Cause it sounds like you already have. 
It should look something like this, in any case:

I think you'll have to drop into an External Method to say

(with parameters: someList)

from AccessControl.User import nobody
user = nobody
retList = []
for obj in someList:
  if user.hasRole(obj,'View'):
    retList.append(obj)
return retList

Then restrict this External method to only Managers via the ZMI.

There are ways to allow a TTW script to import like this, if you really 
want to.

       --jcc