Hello, I am wondering if it's possible to simplify a method I have defined. I have a few classes that are autoloaded:
PlatePointing, Plate, Plugging, PlPlugMapM All are related, and all defined in this manner: class Plate(Base): __tablename__ = 'plate' __table_args__ = {'autoload' : True} Later, I define my relationships. I want to define an attribute that performs a more complicated query, and this works: def platePointing(self,session): try: pp = session.query(PlatePointing)\ .join(Plate, Plugging)\ .filter(Plate.pk==self.plugging.plate.pk)\ .filter(PlatePointing.pointing_name==self.pointing_name).one() except sqlalchemy.orm.exc.NoResultFound: pp = None return pp PlPlugMapM.platePointing = platePointing My question is, can this be written so that I don't need to pass in the session? I don't know how else to perform the query (or return the object) without that. 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 -~----------~----~----~----~------~----~------~--~---