Re: [Zope] Trapping zope exceptions in python script

2005-12-15 Thread Andrew Langmead
On Dec 15, 2005, at 4:01 PM, Nikko Wolf wrote: 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 m

Re: [Zope] Trapping zope exceptions in python script

2005-12-15 Thread Nikko Wolf
Andreas Jung wrote: --On 14. Dezember 2005 12:54:56 -0700 Nikko Wolf <[EMAIL PROTECTED]> wrote: So you could try this instead: for item in itemList: try: context.afolder.manage_delObjects([item]) except: continue Wa... DON'T DO THAT. You should

Re: [Zope] Trapping zope exceptions in python script

2005-12-15 Thread J Cameron Cooper
Jonathan wrote: Andreas wrote: My 2 cents: PythonScripts are restricted and are *not* thought to be a full replacement for Python modules. If you need this functionaltiy consider writing a Zope Product, using external methods or using TrustedExecutables. If python scripts are restricted

Re: [Zope] Trapping zope exceptions in python script

2005-12-15 Thread Andrew Milton
+---[ Joe Bezier ]-- | On 14 Dec 2005, at 19:54, Nikko Wolf wrote: | >In general, TTW coding is very limited; you can use External Methods | >(a.k.a. Extensions) or Products to avoid this. | > | Please excuse my ignorance, but what does "TTW coding" mean exactly? "Through

Re: [Zope] Trapping zope exceptions in python script

2005-12-15 Thread Joe Bezier
On 14 Dec 2005, at 19:54, Nikko Wolf wrote: In general, TTW coding is very limited; you can use External Methods (a.k.a. Extensions) or Products to avoid this. Please excuse my ignorance, but what does "TTW coding" mean exactly? Thanks JB __

Re: [Zope] Trapping zope exceptions in python script

2005-12-15 Thread Jonathan
- Original Message - From: "Tino Wildenhain" <[EMAIL PROTECTED]> To: "Andreas Jung" <[EMAIL PROTECTED]> Cc: "Jonathan" <[EMAIL PROTECTED]>; Sent: Thursday, December 15, 2005 9:15 AM Subject: Re: [Zope] Trapping zope exceptions in p

Re: [Zope] Trapping zope exceptions in python script

2005-12-15 Thread Tino Wildenhain
Andreas Jung schrieb: --On 15. Dezember 2005 09:08:20 -0500 Jonathan <[EMAIL PROTECTED]> wrote: - Original Message - From: "Tino Wildenhain" <[EMAIL PROTECTED]> Interesting work-around, but I agree that these exception types should be immediately available in plain vanilla python scri

Re: [Zope] Trapping zope exceptions in python script

2005-12-15 Thread Andreas Jung
--On 15. Dezember 2005 09:08:20 -0500 Jonathan <[EMAIL PROTECTED]> wrote: - Original Message - From: "Tino Wildenhain" <[EMAIL PROTECTED]> Interesting work-around, but I agree that these exception types should be immediately available in plain vanilla python scripts. Patches + test

Re: [Zope] Trapping zope exceptions in python script

2005-12-15 Thread Jonathan
- Original Message - From: "Tino Wildenhain" <[EMAIL PROTECTED]> To: "Jonathan" <[EMAIL PROTECTED]>; Sent: Thursday, December 15, 2005 8:48 AM Subject: Re: [Zope] Trapping zope exceptions in python script ... Try: context.afolder.manage_delObject

Re: [Zope] Trapping zope exceptions in python script

2005-12-15 Thread Tino Wildenhain
... Try: context.afolder.manage_delObjects(['someitem']) where 'someitem' does not exist in 'afolder' works: try: context.afolder.manage_adlObjects(['nonexistent']) except Exception,x: if 'BadRequest' in repr(x): print "bad request" else: raise x :-) (Ok, this _is_ ug

Re: [Zope] Trapping zope exceptions in python script

2005-12-15 Thread Jonathan
Andreas wrote: My 2 cents: PythonScripts are restricted and are *not* thought to be a full replacement for Python modules. If you need this functionaltiy consider writing a Zope Product, using external methods or using TrustedExecutables. If python scripts are restricted from accessing zExc

Re: [Zope] Trapping zope exceptions in python script

2005-12-15 Thread Jonathan
- Original Message - From: "Tino Wildenhain" <[EMAIL PROTECTED]> To: "Jonathan" <[EMAIL PROTECTED]> Cc: Sent: Thursday, December 15, 2005 8:18 AM Subject: Re: [Zope] Trapping zope exceptions in python script Jonathan schrieb: ... It seems s

Re: [Zope] Trapping zope exceptions in python script

2005-12-15 Thread Tino Wildenhain
Jonathan schrieb: ... It seems strange that one can, using plain vanilla python scripts, trap bare 'try/excepts' (and I agree with Andreas that this is not a good thing to do!) and that one can trap python built-in exceptions, but that one cannot trap zope exceptions. Why allow python scri

Re: [Zope] Trapping zope exceptions in python script

2005-12-15 Thread Andreas Jung
--On 15. Dezember 2005 08:03:22 -0500 Jonathan <[EMAIL PROTECTED]> wrote: - Original Message - From: "J Cameron Cooper" It seems strange that one can, using plain vanilla python scripts, trap bare 'try/excepts' (and I agree with Andreas that this is not a good thing to do!) and th

Re: [Zope] Trapping zope exceptions in python script

2005-12-15 Thread Jonathan
- Original Message - From: "J Cameron Cooper" <[EMAIL PROTECTED]> To: "Jonathan" <[EMAIL PROTECTED]> Cc: Sent: Wednesday, December 14, 2005 4:33 PM Subject: Re: [Zope] Trapping zope exceptions in python script Jonathan wrote: Thanks to everyone for

Re: [Zope] Trapping zope exceptions in python script

2005-12-14 Thread Andreas Jung
--On 14. Dezember 2005 16:20:57 -0500 Jonathan <[EMAIL PROTECTED]> wrote: Thanks to everyone for the feedback... the bottom line seems to be that you can NOT trap zope exceptions in a python script... which seems a bit odd. Nothing is odd. I just told you to avoid *bare* try..excepts..as Ti

Re: [Zope] Trapping zope exceptions in python script

2005-12-14 Thread J Cameron Cooper
Jonathan wrote: Thanks to everyone for the feedback... the bottom line seems to be that you can NOT trap zope exceptions in a python script... which seems a bit odd. Of course you can. You just are restricted from importing certain things, which happens to include this class of exception. Pro

Re: [Zope] Trapping zope exceptions in python script

2005-12-14 Thread Tino Wildenhain
Am Mittwoch, den 14.12.2005, 16:20 -0500 schrieb Jonathan: > Thanks to everyone for the feedback... the bottom line seems to be that you > can NOT trap zope exceptions in a python script... which seems a bit odd. > No, you can. But you should know what you do and reraise critical (e.g. Conflict

Re: [Zope] Trapping zope exceptions in python script

2005-12-14 Thread Jonathan
PROTECTED]>; Sent: Wednesday, December 14, 2005 3:06 PM Subject: Re: [Zope] Trapping zope exceptions in python script ___ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related list

Re: [Zope] Trapping zope exceptions in python script

2005-12-14 Thread Andreas Jung
--On 14. Dezember 2005 12:54:56 -0700 Nikko Wolf <[EMAIL PROTECTED]> wrote: So you could try this instead: for item in itemList: try: context.afolder.manage_delObjects([item]) except: continue Wa... DON'T DO THAT. You should *never* use bare try..ex

Re: [Zope] Trapping zope exceptions in python script

2005-12-14 Thread Nikko Wolf
Jonathan wrote: I am trying to catch a 'BadRequest' exception in the following python script excerpt: for item in itemList: try: context.afolder.manage_delObjects([item]) except BadRequest: continue NameError: global name 'BadRequest' is not defined The following would norma

[Zope] Trapping zope exceptions in python script

2005-12-14 Thread Jonathan
I am trying to catch a 'BadRequest' exception in the following python script excerpt: for item in itemList: try: context.afolder.manage_delObjects([item]) except BadRequest: continue The rationale behind this is that itemList may contain entries that no longer exist in 'afolder'