On Wed, Mar 10, 2004 at 02:56:33PM +0000, Chris Withers wrote:
Marco Bizzarri wrote:
What I would like to do is to have an hook to the removal of a _v_ attribute, so that I can perform some action *BEFORE* losing any reference to the object itself. I look at the setattr code in cPersistence.c and tried also to write my own __setattr__,
__setattr__ isn't the hook you're looking for..
Correct, I discovered that after some digging.
This is better done in a transcation-hooking type way, a la CTM.py in ZOracleDA...
cheers,
Chris
I'm trying something inspired to that at the moment... I succeeded in installing an hack, very inspired from your code (but at a much simpler level) and some code in the SecurityManager, where I mantain a dictionary of connections, indexed by the result of thread.get_ident(). Once a thread needs a new connection, either it is present in the dictionary or not. If it is present, give it to the thread and assign that to the _v_database_connection attribute. Otherwise, create a new one, put in the dictionary, and go on as before. Of course this is a (horrible) hack, because if you have more than one ZPsycopg objects you will end with mixed connections (aaaaargh!) As a proof of concept however it works, and it is resistent to the refreshing of other products (not the ZPsycopg one). Regards Marco
-- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
-- Marco Bizzarri - Amministratore Delegato - Icube S.r.l. Sede: Via Ridolfi 15 - 56124 Pisa (PI), Italia E-mail: m.bizzarri@icube.it WWW: www.icube.it Tel: (+39) 050 97 02 07 Fax: (+39) 050 31 36 588