[Zope] exceptions/documentation problem

Chris Withers chris at simplistix.co.uk
Fri Jul 23 05:41:50 EDT 2004


Dieter Maurer wrote:
>       try:
> 	... do something which may result in an exception of type "E" ...
> 	... do something affecting persistent state (change in ZODB,
> 	    changing an SQL database, ...) ...

If these aren't transactionally aware presistent changes (such as editing a 
disk-absed file) then yes, I'd agree...

> 	... do something which may result in an exception of type "E" ...
>       except E:
>         ... you do not know whether or not the persistent state
> 	    as been changed.

If that's important ot your app, then your try/except should be made smaller ;-)
If the persistent state change was to write something to an event log in SQL, 
then your described behaviour might be required, not just acceptable ;-)

> 	    When you continue without reraising an exception,
> 	    the change may or may not be committed. ...

Well, catching an exception is program flow control. Your statement is the same 
as saying:

if x > 10:
   y = -1
else:
   y = +1

...means you don't knwo what the value of Y will be.

> Note that many standard exceptions ("E" above) can easily be raised
> by code you would not immediately expect.

I'm not sure I beleive this unless you're talking about broken DA's. ZODB 
certainly doesn't do this...

Chris

-- 
Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk



More information about the Zope mailing list