[Zope-DB] Trying to catching ZPsycopg exceptions aborts the transaction

Federico Di Gregorio fog at initd.org
Mon Nov 29 14:13:13 EST 2004


Il giorno lun, 29-11-2004 alle 12:08 +0100, Josef Meile ha scritto:
> Hi,
> 
> I know it may sound strange, but I don't want the DA to abort the
> transaction when trying to insert a duplicate record. The reason of
> doing this is that before trying to insert that duplicate, I have
> already done other inserts, so, they will be rollebacked as well.

don't even go on. :) psycopg will never support that because it will
stand against zope transactional machinery.

> I have already posted this question to the psycopg mailing list (down at
> the moment, so, I can't give you a reference to my message), but there I
> was told that this suits better on a zope related list. The scenario is
> the following:

to be exact we pointed you at managing your own psycopg connection in an
external method or in your own product instead of using ZpsycopgDA.

[snippety snip]
> 4) Working with the "autocommit" method of the psycopg cursors. This is
> almost the solution. The only problem here is that each insert will be
> considered as an individual transaction, so, if for some reason the
> server crashes, the previously inserted records won't be rollbacked and
> there will be some inconsistencies. Other disadvantage is that doing
> this wouldn't be standard because it is psycopg specific.

i suppose all db adapters support what is called "0 isolation level" or
"autocommit". unfortunately a standard method to switch isolation level
is not specified in the DBAPI document.

anyway I am curious about what other people have to say on your specific
problem. I myself would have used a single row for every reservation,
iterating over smaller and smaller time ranges until the right one is
found.

federico




More information about the Zope-DB mailing list