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
-~----------~----~----~----~------~----~------~--~---

Reply via email to