Hi,

I may have got it. The thread entitled "Usage of sqlalchemy session
objects in turbogears" was quite helpful and exactly what I'm trying
to do. For others, this is what I have done. I have an existing
SQLAlchemy class that I use outside of TG (and need to keep it that
way). I removed any import of the built in model, which meant I needed
to implement my own session. What I did above was ok:

Session = scoped_session(sessionmaker(...))

Then I import it as such in the file controllers/__init__.py so it's
available to all controllers:

from mySAwrapper import Session as session

Then I can perform queries as expected on demand - no other setup/
cleaning.

session.query(...)

The scoped_session is the bit that instantiates sessions as needed.

I'm still not 100% sure all this is right, but I think I'm a lot
closer.

Cheers,
Demitri
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to