Re: [SQLObject] Hello and Connections (to start)
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
|
From: Ian B. <ia...@co...> - 2003-03-13 03:48:20
|
On Wed, 2003-03-12 at 01:17, Luke Opperman wrote:
> --------> local PostgresConnection.py code
>
> from SQLObject import PostgresConnection as PC
> import psycopg
> from PoolStore import PoolStore
> import threading
>
> _store = PoolStore(psycopg, maxPerDSN=10, total=65)
>
> class PostgresConnection(PC):
>
> def __init__(self, dsn, debug=0):
> self.dsn = dsn
> self.debug = debug
> self.instanceCache = {}
> self.instanceCacheLock = threading.Lock()
>
> def getConnection(self):
> return _store.getConnection(self.dsn)
>
> def releaseConnection(self,conn):
> conn.close()
>
> def makeConnection(self):
> pass
This looks like the right way to go about this. You should call the
parent __init__, though. More like:
def __init__(dsn, debug=0):
PostgresConnection.__init__(dsn, debug=debug)
Though you don't *really* have to override __init__ at all, except if
you want to disallow non-applicable init arguments.
Ian
|