[PEAK] data manager, connections oh my
Phillip J. Eby
pje at telecommunity.com
Wed Jan 7 15:13:20 EST 2004
At 12:32 PM 1/7/04 -0600, darryl wrote:
>Hey,
>
>I have a bunch of stuff in a roundup tracker (http://roundup.sf.net) which
>I want to access via roundup's api. My first thought was to
>write DataManagers which use the API to get my data in a PEAK-ish way.
>
>Now, i guess the problem is, that roundup sets a global lock on everything
>when a connection is opened. What this means is while
>i have a connection open i cannot use roundup via the webUI.
>So what i need is a way to close the connection after every transaction.
>
>So i'm just throwing this out there for some guidance. Does the question
>even make sense? Did i even ask a question?
Well, if you wrap your roundup connection in a ManagedConnection subclass,
you can have it automatically close at the finish of each transaction. All
you should need to do are override in your subclass are _open(), _close(),
cursorClass, and _closeASAP. Something like:
class RoundupConnection(storage.ManagedConnection):
_closeASAP = True # force close after every transaction
def _open(self):
self.joinTxn() # ensure that we can only be opened in a transaction
# now open the real roundup object and return it
def _close(self):
# do anything needed to 'self.connection' to close it
cursorClass = RoundupCursor
Of course, you'll need to also create a RoundupCursor class, with an
'execute()' method that takes positional arguments. What it does with
those arguments and how it returns results is up to you, of course. You'll
probably want to subclass AbstractCursor. Note that keyword arguments
passed to the connection's __call__ method are forwarded to the cursor
class' constructor when creating cursors.
More information about the PEAK
mailing list