[Zope] adding properties trough pythonscript

Dieter Maurer dieter at handshake.de
Sun Oct 17 16:44:29 EDT 2004


massimop at users.berlios.de wrote at 2004-10-16 12:23 +0200:
> ...
>> Do not use "try: ... except:...". It is dangerous. It can easily
>> lead to ZODB inconsistencies...
>
>not exactly good news to me....
>
>can you point out some document explaining this?

It follows from common sense (and therefore need no documentation ;-)

  Python's exceptions are abortive: as soon an exceptin is raise,
  the normal flow of control is aborted.

  When you have modified persistent state before the exception occured,
  the transaction must usually be aborted, to get the modifications
  reverted. If instead, the transaction is committed, the (often)
  partial change is made persistent.

  Usually, the Zope framework does this for you.
  However, when you catch an exception, the framework may
  not learn about the problem and commit rather than abort.

  As I wrote, this can easily lead to corruption of persistent
  data.

>can I raise exceptions from a python script?

Yes.

-- 
Dieter


More information about the Zope mailing list