> I finally ended up putting the connection in > MyController.__before__(). That way it's created only in controllers > that actually use the database,and it's one less module to modify. > But I still want to see if it's possible to use one connection for > several requests.
The usual way is to use a global dictionary that holds the connections indexed by the thread id. Something like this should work: id = thread.get_ident() global conn_cache conn = conn_cache.get(id, newconnection()) Something like this is implemented in the threading.local() class which is new in Python 2.4 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to pylons-discuss@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~----------~----~----~----~------~----~------~--~---