<br>Hi!<br><br>I just started looking at zope, so this might be a pretty nooby question, but I didnt find an answere anywhere, so...<br><br>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
<br>
AccessControl.unauthorized.Unauthorized exception when I call the method. <br><br>I did a litle python script that iterates over the objectValues and catches the errors raised from unauthorized files as folows:<br><br>files = []
<br>fileIterator = iter(container.objectValues('File'))<br>while True:<br> try: <br> files.append(fileIterator.next())<br> except Exception, e:<br> if isinstance(e,StopIteration):<br> break
<br> else:<br> files.append(e)<br>return files<br><br>
<p class="MsoNormal"><span style="" lang="EN-GB">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.
</span></p>
<p class="MsoNormal"><span style="" lang="EN-GB">So my question
is, how do I do this in a nicer way?</span></p>
Thanx /Erik<br><br>