Hi, I'm trying to create a custom/derived attribute on a table class. This is what I have defined:
class Plate(Base): __tablename__ = 'plate' __table_args__ = {'autoload' : True} class Design(Base): __tablename__ = 'design' __table_args__ = {'autoload' : True} class Pointing(Base): __tablename__ = 'design' __table_args__ = {'autoload' : True} I then map these together: Plate.design = relation(Design, primaryjoin=Plate.design_pk == Design.pk, backref="plate") Design.pointings = relation(Pointing, primaryjoin=Design.pk == Pointing.design_pk, backref="design") (So a plate has one design, and a design can have multiple pointings. Sorry for the jargon.) All of this works. I'd like to be able to write a convenience method to access data in "plugging" directly from "plate", for example, instead of doing: plate.design.pointings[0].center_ra I'd like to be able to say: plate.ra How can I create this attribute? I've tried something like: Plate.ra = column_property(Plate.__table__.design.pointings [0].center_ra) but I get: AttributeError: 'Table' object has no attribute 'design' For extra credit, is it possible to write a method on Plate that I can use like this? plugging_no = 0 plate.ra(plugging_no) It's easy to do these things in the Plate class definition, but at the time I define it the other classes/tables are not defined (nor the mappings). Cheers, Demitri --~--~---------~--~----~------------~-------~--~----~ 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 sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---