[sqlalchemy] Re: Adding a filter_by() clause by default.

2008-06-25 Thread Huy Do

Michael Bayer wrote:
 using 0.5:

 from sqlalchemy.orm import Query, sessionmaker

 class MyQuery(Query):
 def __new__(cls, entities, **kwargs):
 if hasattr(entities[0], 'deleted_at'):
 return Query(entities,
 **kwargs).filter_by(deleted_at=None)
 else:
 return object.__new__(cls)

 Session = sessionmaker(query_cls=MyQuery)
   
This is cool stuff.

huy

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Adding a filter_by() clause by default.

2008-06-23 Thread Michael Bayer

using 0.5:

from sqlalchemy.orm import Query, sessionmaker

class MyQuery(Query):
def __new__(cls, entities, **kwargs):
if hasattr(entities[0], 'deleted_at'):
return Query(entities,
**kwargs).filter_by(deleted_at=None)
else:
return object.__new__(cls)

Session = sessionmaker(query_cls=MyQuery)

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~--~~~~--~~--~--~---