Hi Tomasz,

Thanks for your help - that solved the problem.

On 26 Sep 2009, at 10:20, Tomasz Jezierski - Tefnet wrote:

[...code snipped...]

> First... why don't you define this method with class definition? I  
> don't
> use "reflection" but I think that it is possible...

It's a chicken-and-the-egg problem. I can't use the other classes  
(that I include in the "join" statement, for example), until they are  
defined, but as many tables are interrelated, that's not possible to  
do up front. Unless there is a way to do it that I'm missing.

> Second... you could probably convert it to column_property

I'm not sure how I would do that...

> And back to your question..
> 1. you can have globally accessed session (like it is done in Pylons  
> via
> meta.Session)
> http://wiki.pylonshq.com/display/pylonsdocs/Using+SQLAlchemy+with+Pylons

Not a bad idea, but the class is being used by many scripts as well as  
a TurboGears app, so I can't make that assumption.

> 2. you can get session for instance using
> sqlalchemy.orm.session.Session.object_session
> http://www.sqlalchemy.org/docs/05/reference/orm/sessions.html?highlight=session#sqlalchemy.orm.session.Session.object_session

This is exactly the method I was looking for and have used. I expected  
it to be in the Base class and didn't think to look in Session.

> 3. You can have "session-aware class"
> http://www.sqlalchemy.org/trac/wiki/UsageRecipes/SessionAwareMapper

Thanks for that link. Unfortunately, my eyes kind of glazed over when  
I tried to go through it...

Cheers,
Demitri

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to