[Zope] Checking zope userfolder root

Oliver Bleutgen myzope@gmx.net
Wed, 18 Sep 2002 15:56:30 +0200


chrisf wrote:
> 
> Oliver Bleutgen wrote:
> 
> 
>>Anyway, as Chris stated, you just have to catch the unauthorized exception:
>>
>>try:
>>   if getattr(item[1],'index_html'):pub.append(item[1].absolute_url())
>>except:
>>   pass (or do something)
>>
>>You can further qualify which exception you want to capture, I don't
>>know offhand if
>>...
>>except Unauthorized:
>>   pass
>>
>>works.
> 
> 
> Not from within a Zope ZClass product.
> I get the dumb Authorization window regaurdless.
> If I fail to input the correct info then I get the exception.
> Try it :)
> 
> Thanks for the help,


Please stay on the list, I've not given up ;-).
Since the try/except clause didn't work, it's quite clear that getattr 
isn't raising the exception. Maybe it happens inside ZopeFind.

ZopeFind also has the possibility to limit search results based on 
permission (see the "advanced" tab under Find in the ZMI.

IIRC, you can use something like
ZopeFind(..., obj_permission=[list of permissions], obj_roles=[list of 
roles]), where you define which roles should have which permission on 
the object.
Another possiblity is to use obj_expr="something", where something tests 
if the actual user is allowed to view the object.

cheers,
oliver