since this is the second time in three days and third time in two
months this question has been asked, I've located my original answer
from may and posted it on the wiki at
http://www.sqlalchemy.org/trac/wiki/UsageRecipes/PreFilteredQuery
.
On Jul 3, 2009, at 9:39 PM, cd34 wrote:
>
> I'm trying to overload session for an application so that I can add a
> filter to every query without having to manually enter it. I
> understand that session is a method, but, I haven't quite figured out
> what is required to add my filter.
>
> I have the following:
>
> engine = create_engine('mysql://user:passw...@localhost/database')
> session = sessionmaker(bind=engine)
> DBSession = session()
>
> class clientSession(session):
> def query(self, *entities, **kwargs):
> #self._query_cls.filter('clients.client_id==1')
> return self._query_cls(entities, self, **kwargs)
>
> clients = cs.query(clients).limit(5).all()
> print clients
>
> What I would like to accomplish is have a class that I can call that
> always issues .filter('clients.client_id==value') on a query and
> update.
>
> I've searched google at length, but, haven't stumbled across the
> solution and am hoping someone can at least point me in the right
> direction.
>
> Thanks.
>
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---