integrate ORM with CherryPy pool
parent
6991d70eb3
commit
99a5e6f8d3
|
@ -66,12 +66,13 @@ class ConnectionPool(plugins.SimplePlugin):
|
||||||
recycle=recycle)
|
recycle=recycle)
|
||||||
engine = create_engine(DUMMY_SQL_URL, echo=False, pool=my_pool)
|
engine = create_engine(DUMMY_SQL_URL, echo=False, pool=my_pool)
|
||||||
Session = sessionmaker(bind=engine)
|
Session = sessionmaker(bind=engine)
|
||||||
return my_pool, Session
|
return engine, Session
|
||||||
|
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
""" Return a connection. """
|
""" Return a connection. """
|
||||||
|
|
||||||
return self.pool.connect()
|
return self.pool.raw_connection()
|
||||||
|
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
|
@ -100,7 +101,7 @@ class ConnectionPool(plugins.SimplePlugin):
|
||||||
if self.pool is not None:
|
if self.pool is not None:
|
||||||
self.bus.log("Restarting the SQL connection pool ...")
|
self.bus.log("Restarting the SQL connection pool ...")
|
||||||
self.pool.dispose()
|
self.pool.dispose()
|
||||||
self.pool = self._start()
|
self.pool, self.Session = self._start()
|
||||||
|
|
||||||
|
|
||||||
cherrypy.process.plugins.ConnectionPool = ConnectionPool
|
cherrypy.process.plugins.ConnectionPool = ConnectionPool
|
||||||
|
|
Loading…
Reference in New Issue