I just started looking at zope, so this might be a pretty nooby question, but I didnt find an answere anywhere, so...

I want to create a DTML Method that lists the files in a folder that the current user has access to. Problem is that the objectValues-method returns all files simultaniously, so I get a
AccessControl.unauthorized.Unauthorized exception when I call the method.

I did a litle python script that iterates over the objectValues and catches the errors raised from unauthorized files as folows:

files = []
fileIterator = iter(container.objectValues('File'))
while True:
    except Exception, e:
        if isinstance(e,StopIteration):
return files

This works fine, except that it's a bit clumsy and has one big error; I catch just any exception that arises from the files.append(fileIterator.next())-call, and swallow it. I've tried catching only the Unauthorized-exception, but an anonymus user does not have access to the Unauthorized-exception, so I can't specify is in my except-declaration without getting a new authorization error. All thaw it works fine to catch all exceptions for a simple directory listing like this, its defiantly nothing I wanna put into a larger application.

So my question is, how do I do this in a nicer way?

Thanx /Erik

Zope maillist  -  Zope@zope.org
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to