[Zope] exceptions/documentation problem

Dieter Maurer dieter at handshake.de
Thu Jul 22 13:49:05 EDT 2004


Chris Withers wrote at 2004-7-21 16:25 +0100:
>Dieter Maurer wrote:
>> But, whenever code in the "try" block modifies any persistent storage
>> the chance of inconsistencies is indeed high.
>
>Can you explain why?
>
>The only problem I can think of is generic except: clauses catching conflict errors.
>
>What other sources of inconsistencies are there?

      try:
	... do something which may result in an exception of type "E" ...
	... do something affecting persistent state (change in ZODB,
	    changing an SQL database, ...) ...
	... 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.
	    When you continue without reraising an exception,
	    the change may or may not be committed. ...

      ... do something affection persistent state 
          now you may have got an inconsistency (when the first
	  change did not happen) ...

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

-- 
Dieter


More information about the Zope mailing list