Ah ok. Basically, yeah, I'm trying to put all the 'mapper' type behaviors in one place, instead of having some of the properties specified where I declare the mapper, and others declared as functions in the class itself. There might be a better python-esque way of doing this, I admit, but I just thought that there should be a way of doing it as a mapper property instead of as a seperate clause.
How about getting a different existing Table object for a table that's not mapped to a class? I don't want to call Table(...,autoload=True) again because that sounds like it'd load the entire metadata for the table each time the function was called. Can I walk my way through the metadata object or something? Cheers, --Benn On Apr 7, 4:15 pm, Michael Bayer <[EMAIL PROTECTED]> wrote: > there is a "blue sky" kind of idea to add a "lazyloader()" > MapperProperty construct which could accept any callable, such as the > one you have below, and it would be called in the same manner as any > other lazy loader. But youd still be writing out more or less that > function. im not sure what need youre trying to fill, strictly that > the function should be defined in the same place as the mapper? you > could just attach your "dependencies" function onto your Command > class at any point in your application. > > anyway, to get the mapped table for a class: > > class_mapper(Command).mapped_table > > On Apr 7, 2007, at 6:43 PM, Benn Bollay wrote: > > > > > Hi all - > > > I want to convert a handful of complicated queries into properties, > > for simplicity and ease of maintaince. > > > I currently have a function in my class called 'dependencies': > > > def dependencies(self): > > parent = DataRun.CMDS.alias('PARENT') > > return object_session(self).query(Command).select( > > and_(parent.c.target_id == self.target_id), > > from_obj=[ > > join(parent, DataRun.DEPS, > > parent.c.target_id == DataRun.DEPS.c.target_id).join( > > DataRun.CMDS, DataRun.DEPS.c.dep == > > DataRun.CMDS.c.name)]) > > > This works correctly. I'd like to reduce this to an entry in my > > mapper() statement. > > mapper(Command, DataRun.CMDS) > > > Alternately, if that's not possible, I'd like to determine how to get > > to the table object for CMDS, DEPS objects (which are just table's) > > without using the global DataRun. Are there variables associated with > > mapped classes that I can use to build references to other tables? > > > Cheers, > > --Benn --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---