On Jan 26, 11:57 am, "King Simon-NFHD78" <[email protected]>
wrote:
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[email protected]] On Behalf Of Boda Cydo
> > Sent: 26 January 2010 01:35
> > To: sqlalchemy
> > Subject: [sqlalchemy] Re: Is it possible to narrow down the
> > generated query in SQLAlchemy if it was created via query_property?
>
> > On Jan 25, 2:46 am, Boda Cydo <[email protected]> wrote:
> > > Let me know if the question is not clearly stated. I'll
> > update it with
> > > more details.
>
> > Any ideas?
>
> When you access Comment.query, you are getting back an already instantiated 
> Query object which, as the error message indicates, isn't callable.
>
> I guess I don't really understand why you want to use 
> Comment.query(Comment.comment) rather than Session.query(Comment.comment). If 
> you really want this, you could subclass Query to add a __call__ method that 
> creates a new query instance:
>
> class CallableQuery(Query):
>     def __call__(self, *args, **kwargs):
>         return Session.query(*args, **kwargs)
>
> class Comments(Base):
>     query = Session.query_property(query_cls=CallableQuery)
>
> ...but I'm still not sure what the point is.
>


Thanks for pointing out the idea of adding a __call__ method. I would
not have thought of it myself if you hadn't mentioned it. Also thanks
for suggesting to use Session.query() instead of Comments.query.


Boda Cydo.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" 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/sqlalchemy?hl=en.

Reply via email to