On Jun 27, 2006, at 3:22 PM, Randall Smith wrote: > I'm aware of both methods, the later better than the former. I should > have stated that I am working with sqlalchemy.objectstore. It works > like a normal session, but since it is created automatically after > importing mods.threadlocal, there is no opportunity to bind it to an > engine as there is with create_session. Instead, it seems > metadata.connect() is the only way to bind an engine before using > sqlalchemy.objectstore. Is this correct? >
the session created by sqlalchemy.objectstore could be bound to an engine as well, it would probably be easier to use the SessionContext plugin directly rather than using the "threadlocal" mod, so that you can easily define the "create_session" callable to use. Really, Turbogears should probably be using SessionContext directly and probably build some API on top of that, possibly one that uses engine-bound sessions (that way tables dont need to be bound to engines). "sqlalchemy.objectstore" is just an example usage of SessionContext which is probably a little rigid for building into an existing framework. > When using sqlalchemy.objectstore, would it be a good idea to call > objectstore.clear() (or close?) at then end of an operation? yeah, you should call clear() at the end (or at the beginning of each request, if that works better....), since with a thread local session like that, the next request is going to come around and re-use it, and its best that its empty before you start doing anything with it. and yes also you dont want it to keep growing. this is an area where Turbogears might want to look into having a Session created on a request-local, rather than a thread-local basis. again, building out from SessionContext would be the way to go with this. that way, new Session for each request, when the request is over the whole Session is gone. Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users