On Thursday, January 3, 2013 9:31:37 PM UTC+1, Michael Bayer wrote: > > > On Jan 3, 2013, at 3:17 PM, sjo...@congressus.nl <javascript:> wrote: > > In this MyQuery two things need to happen; A) check whether the queried table > has the certain company_id field and B) automatically implement the > additional filter to add the SomeHTTPSessionGlobal.company_id (which is based > on the sub-domain) > => Is by altering the get(), __ite__ and from_self() functions enough to > effect all queries? > => How to get the adjusted table and detect whether an company_id field > exists? > > > > the vast majority of queries go through __iter__(), so that's probably all > you need. from_self() and get() are not as common - though get() will be > used for a many-to-one lazy load in most cases, if this class is the target > of a many-to-one relationship(). > > If you're dealing with mapped classes, a simple enough check is > hasattr(MyClass, 'company_id'). Within Query, calling > _mapper_zero().class_ gives you this class, assuming the query is against a > single full entity like query(MyClass). > > > It is working, thanks for your help and additional explanation!
-- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/xevfhT4NZlUJ. 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.