I'm trying to subclass DBPool so that it takes the connections out of
transaction mode when they are created and I'd like to do it in such a
way that if DBPool is updated, my subclass will still work properly but
I don't think the hooks are there for it.

My attempt was this:

class DBPoolNoTrans(DBPool):
        def _threadsafe_addConnection(self, con):
                con.cursor().execute("rollback")
                DBPool._threadsafe_addConnection(self, con)

        def _unthreadsafe_addConnection(self, con):
                con.cursor().execute("rollback")
                DBPool._unthreadsafe_addConnection(self, con)


Unfortunately, the un-thread safe version (postgres) calls addConnection
every time the connection is returned to the pool.  The thread safe
version only calls addConnection only at initialization which is what I
desire.  Could we break addConnection into two methods, one for init,
another for adding an existing connection back to the queue?

My final subclass is this which works but has too much knowledge of the
internals of DBPool.

class DBPoolNoTrans(DBPool):
        def _threadsafe_addConnection(self, con):
                con.cursor().execute("rollback")
                DBPool._threadsafe_addConnection(self, con)

        def _unthreadsafe_addConnection(self, con):
                con.cursor().execute("rollback")
                DBPool._unthreadsafe_addConnection(self, con)

        def _unthreadsafe_reAddConnection(self, con):
                self._queue.put(con)

        def _unthreadsafe_returnConnection(self, conpool):
                """
                This should never be called explicitly outside of this
module.
                """
                #self.addConnection(conpool._con)
                self._unthreadsafe_reAddConnection(conpool._con)



-Jeff




_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss

Reply via email to