Re: PATCH: two phase commit

Federico Di Gregorio <fog-NGVKUo/i/[email protected]>
Newsgroups gmane.comp.python.db.psycopg.devel
Organization initd.org
Message-ID <[email protected]>
Il giorno ven, 18/01/2008 alle 00.08 +0900, James Henstridge ha scritto:
> These are the basic operations needed to plug a psycopg2 connection
> into a transaction manager so it would be possible to properly
> participate in Zope two phase commit, as an example.
>
> I've included basic tests of the new methods.

Mm.. I am sorry but I don't like adding another 3 methods to the
connection object. Also before going on extending the API it is
customary to seek comments on the DBAPI list where other people may
already have implemented the feature (two phase commit here).

Anyway, my argument against this API is that passing around the
transaction xid it isn't very pythonic. A better approach would be to
create a transaction object that olds the xid and has commit and
rollback methods. Also, the prepared transaction can be commited or
rolled back from a different session so it would be nice to have the
ability to give the transaction object to a new connection, etc.

trans = conn.prepare_transaction()      # autogenerate xid
trans = conn.prepare_transaction(xid)   # xid as argument
trans = conn.prepare_transaction(told)  # extrac xid from old trans

print trans.xid -> prints the xid

trans.commit()
trans.rollback() 

-- 
Federico Di Gregorio                         http://people.initd.org/fog
Debian GNU/Linux Developer                                [email protected]
INIT.D Developer                                           fog-NGVKUo/i/[email protected]
                   Datemi uno spigolo. Che lo arrotondo tutto. -- <dani>

_______________________________________________
Psycopg mailing list
Psycopg-IAPFreCvJWPBWskQ1e/[email protected]
http://lists.initd.org/mailman/listinfo/psycopg
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQBHj3lTvcCgrgZGjesRAstcAJ9clTZS91rFIrS+ce+D27RMG0BGsQCfTzkn
VVXWZIjxfEmDXenXFlZ7Yws=
=shrl
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.