I breifly played around with using Warren Smith's DBConnectionPool class on some stuff
(I'm surprised he hasn't responded in this thread yet). I think you can get his
pooling module from the webware sandbox. His pooling module allows for a separate
thread to run and handle some of the connection management (old/stale connections). To
implement it, I put some of the setup in the sitepage (class level and module level).
See my example below. Anyone please correct me if I'm wrong in my implementation.
--John
--== sitepage (DBtestpage.py) ==--
from DbConnectionPool import DbConnectionPool
from WebKit.Page import Page
#from pyPgSQL import PgSQL as db_mod
import sys
import PyIngres as db_mod
maxPoolSize = 10 # 0 or None for unlimited
dbPool = DbConnectionPool(maxPoolSize, db_mod, {'database':'foo','user':'bar'})
dbPool.startExpiration(expireIntervalSeconds=10, maxIdleSeconds=20, maxAgeSeconds=30,
aggressiveExpiration=True)
class DBtestpage(Page):
def __init__(self):
global dbPool
self._dbPool = dbPool
Page.__init__(self)
def getDBPool(self):
return self._dbPool
def writeContent(self):
#self.writeln('DBtestpage')
self.response().sendRedirect('DBtest.py')
def __del__(self):
self.writeln('in __del__')
#self._dbPool.stopExpiration()
Page.__del__(self)
--== servlet page (DBtest.py) ==--
from DBtestpage import DBtestpage
class DBtest(DBtestpage):
def __init__(self):
DBtestpage.__init__(self)
def writeContent(self):
try:
conn = self.getDBPool().getConnection()
except:
# problem, bail
return
else:
self.writeln('successful.')
-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss