On Jul 25, 2009, at 7:24 AM, robert rottermann wrote:
>
> Werner F. Bruhin schrieb:
>>
> this is exactly what I would like to do *within* the instance by
> calling one of
> its methods.
> the reason is, that there are many different product-types and each
> one has its
> own class that uses a common mixin class.
> each such class is associated with a different table and therefore
> an other
> relation.
> so the compay-class has in fact many relations and I want to avoid
> that I have
> to know to what relation I have to add the product.
>
>
> class Products_hlwdHandler(ProductMixin):
> tblClass = tblProducts_hlwd
> FIELDS = PRODUCTS_HLWD_FIELDS
> COMPANY_ID = 'company_id'
> COMPANY_FIELD = 'related_hlwdProducts'
>
> class Products_klHandler(ProductMixin):
> tblClass = tblProducts_kl
> FIELDS = PRODUCTS_KL_FIELDS
> COMPANY_ID = 'company_id'
> COMPANY_FIELD = 'related_klProducts'
> ....
>
> as you can see. each such class knows its relation within the
> companyCL class
> definiton (for Products_hlwdHandler it is 'related_hlwdProducts') to
> which it
> could associate itself. If only it knew "its" id ..
whats wrong with doing the append operation inside of a method ?
def append_something(self, id):
company = query.filter(...).one()
self.whatever_collection_i_want.append(company)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---