Hopefully, you observe that it does *NOT* depend on the type of errors you are trapping but whether or not you changed (in the try block) persistent state *before* the exception occurred (in this block).
I do not yet understanding that part. My second example was: 1 def fooEdit(self,REQUEST): 2 "foo is a string - foo2 is an int" 3 try: 4 self.foo = REQUEST.get('foo','') 5 self.foo2 = int(REQUEST.get('foo2',0) 6 except ValueError, e: 7 self.foo2 = 0 Here I am modifying the persistent object's "foo" property in line 4, then trapping an exception that the "int" function could raise in line 5. Unless line 4 can also raise a ValueError (and I don't think it can), why am I not safe in assuming one of these three cases? A. A ValueError raised in line 5 will leave "foo" set properly from the REQUEST, while "foo2" gets set to 0. B. Some other Exception raised in line 4 or 5 will cause Zope to roll back the transaction and no properties are changed on this try. C. No Exceptions occur, and leave both properties are set correctly from the REQUEST. --Sean
-----Original Message----- From: Dieter Maurer [mailto:dieter@handshake.de] Sent: Friday, October 22, 2004 1:40 PM To: Sean Hastings Cc: massimop@users.berlios.de; zope list Subject: RE: [Zope] adding properties trough pythonscript
Sean Hastings wrote at 2004-10-21 16:22 -0400:
Cool!
I already have a whole bunch of code that uses this sort of error checking, and I wanted to make sure that as long as I was careful to specify the errors I am trapping that I don't have to rewrite it all.
-- Dieter