Twist: Talking to the ZODB in Twisted Reactor Calls
The twist package contains a few functions and classes, but primarily a helper for having
a deferred call on a callable persistent object, or on a method on a persistent object.
This lets you have a Twisted reactor call or a Twisted deferred callback affect the ZODB.
Everything can be done within the main thread, so it can be full-bore Twisted usage,
without threads. There are a few important "gotchas": see the Gotchas section below for
details.
The main API is Partial. You can pass it a callable persistent object, a method of a
persistent object, or a normal non-persistent callable, and any arguments or keyword
arguments of the same sort. DO NOT use non-persistent data structures (such as lists) of
persistent objects with a database connection as arguments. This is your responsibility.
If nothing is persistent, the partial will not bother to get a connection, and will
behave normally.
|