> -----Original Message-----
> From: sqlalchemy@googlegroups.com 
> [mailto:sqlalch...@googlegroups.com] On Behalf Of naktinis
> Sent: 27 July 2009 13:07
> To: sqlalchemy
> Subject: [sqlalchemy] Session mapper and Class.query() method
> 
> 
> I've seen that Session.mapper is deprecated. While I agree that auto-
> adding objects to a session may be a bad idea, I don't see why is it
> so bad to add the query() method directly to the mapped class.
> 
> Is there a reason, why I shouldn't do it?
>

The query() method assumes that you are using a scoped session. As long
as you know that you are always going to use a scoped session, you can
use:

  cls.query = scoped_session.query_property()

...to add it back in again. If you ever use explicit sessions, it might
be confusing that sometimes you say "cls.query()", and other times say
"session.query(cls)", but that's up to you. That's the only reason I can
think of for being cautious about cls.query().

Simon

--~--~---------~--~----~------------~-------~--~----~
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