[Twisted-Python] Deferred database transaction confusion

Lucas Taylor lucas at lucaserve.com
Wed Aug 13 04:04:17 MDT 2003


Greetings!

I'm trying to figure out the best way to accomplish database
transactions and I haven't quite got my head wrapped around deferreds
and the adbapi. I'm hoping someone can nudge me in the right direction.

Basically, we have simple terminals that communicate over dialup lines
to a host server. The host server essentially handles the modem
negotiation and passes everything else through to our Twisted server. We
process the transaction and return the result to the client, and the
protocol specifies an ACK is to be returned on successful receipt. So
I've got a dictionary of transport.sessionnos which hold the ACK state
of the connection. Once the terminal has ACKed the host server, it
passes that along to the Twisted server and drops the connection. On
connectionLost I lookup the ACK value of the connection to make sure the
terminal rx'd the data and then I should be able to commit or rollback
any pending db transactions.

Now here's where I'm stuck. I've got a rudimentary idea of how I will be
chaining callbacks to the deferred results of my db interactions, and
once complete the data will be sent to the terminal. And the registered
errbacks need to be able to rollback if necessary. But how do I get the
protocol handler to access the database connection to issue the
commit/rollback?

btw, thanks to the developers for making my project so incredibly
'do-able'. It's really quite cool - I was able to demo a proof of
concept in an evening after downloading Twisted. The protocol handling
was so easy to setup for what we needed that it was silly.


Thanks,

Lucas Taylor





More information about the Twisted-Python mailing list