I can't find anything related to this at: http://www.sqlalchemy.org/docs/05/sqlalchemy_orm.html My code is :
class Warehouse(object): def __init__(self,id,construction_id,area_total,area_storage): self.id = id self.construction_id = construction_id self.area_total = area_total self.area_storage = area_storage def __repr__(self): return "%s" % self.id class AreaProxy(object): def __getattr__(self, key): return getattr(Warehouse, "area_" + key) area = AreaProxy() And this isn't working becouse: Warehouse.area.total returns .area_total Did i implement this wrong? On 13 Paź, 21:09, Michael Bayer <[EMAIL PROTECTED]> wrote: > On Oct 13, 2008, at 2:50 PM, g00fy wrote: > > > > > How this Proxy object is going to work exacly? > > Will that generate extra Sql or what? > > I assume that I should just change __getattr__() to desired and return > > Warehouse.key ? or warehouse_table.c.key? > > the proxy, which actually should read: > > class Proxy(object): > def __getattr__(self, key): > return getattr(Warehouse, "area_" + key) > > works only at the class level and translates someting like > Warehouse.area.office into Warehouse.area_office. It's merely a > Python trick to change how you access a particular class-level > attribute. > > SQLA 0.4 and above prefer class-level attributes to create expression > predicates. The ORM tutorials for 0.4 and 0.5 cover this in depth. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---