[Zope] Trapping zope exceptions in python script

Nikko Wolf nikko-wolf at earthlink.net
Thu Dec 15 16:01:07 EST 2005


Andreas Jung wrote:

>
>
> --On 14. Dezember 2005 12:54:56 -0700 Nikko Wolf 
> <nikko-wolf at earthlink.net> wrote:
>
>> So you could try this instead:
>>
>>     for item in itemList:
>>        try:
>>           context.afolder.manage_delObjects([item])
>>        except:
>>           continue
>
>
> Wahhhh... DON'T DO THAT. You should *never* use bare try..excepts 
> within Zope applications. This can lead to strange and unpredictable 
> behavior.
>
Can you elaborate on what "strange and unpredictable behavior" you 
mean?  I'm curious in general, but especially w.r.t. the code above?

BTW, a simple grep of sources in Zope (2.7.6-final) turns up 600+ places 
where a bare except is used, and my Zope instance (which uses Plone) 
contains over 350 more.

Cheers,
Nikko




More information about the Zope mailing list