[Zope-dev] Usage of try: .. except: .. in zope
Ivo van der Wijk
ivo@amaze.nl
Sun, 10 Mar 2002 12:33:53 +0100
Hi All,
I'm currently implementing a QuotaFolder for Zope, i.e. a Folder
that restricts the number of objects, their sizes and their total
size (and in the future: the installabe meta types).
Things look very promising (if anyone feels like testing, please mail
me), but it took me quite a while to fix one bug:
When creating a ZopeTutorial in a QuotaFolder, I always got
Error Type: Bad Request
Error Value: The id "examples" is invalid--it is already in use.
I couldn't really figure out why my QuotaFolder would cause ZopeTutorial
to be installed (or actually imported) twice. Until I studied its code:
In addTutorial in TutorialTopic.py, there's the following piece of
importing code:
# work around old Zope bug in importing
try:
folder.manage_importObject(tutorialExamplesFile)
except:
folder._p_jar=self.Destination()._p_jar
folder.manage_importObject(tutorialExamplesFile)
Basically, anything can go wrong in the first manage_importObject (and
in my case it was the raising of a QuotaExceeded exception), causing
the code to try to import the file *again*
Isn't there a better/cleaner way to do this? It this Exception-type-less
try/except construct used elsewhere in Zope (I think I've seen it before)?
Should I put a request in the collector?
Cheers,
Ivo
--
Drs. I.R. van der Wijk -=-
Brouwersgracht 132 Amaze Internet Services V.O.F.
1013 HA Amsterdam, NL -=-
Tel: +31-20-4688336 Linux/Web/Zope/SQL/MMBase
Fax: +31-20-4688337 Network Solutions
Web: http://www.amaze.nl/ Consultancy
Email: ivo@amaze.nl -=-