[sqlalchemy] Re: Dynamically adding MapperExtension

2007-03-13 Thread percious
I think I came up with a decent solution for this: I do something like: extension = MyMapperExtension() for mapper in mapper_registry.values(): mapper.extension = extension mapper._compile_extensions() If you want all classes currently defined in the metadata to map to your new

[sqlalchemy] Re: Dynamically adding MapperExtension

2007-02-09 Thread Michael Bayer
percious wrote: question. Lets say I have a series of table definitions, and a series of objects linked to the tables with a bunch of mappers. First question: Is there a way to get from the table definitions in the metadata to the Mapper? not conveniently. you could loop through the

[sqlalchemy] Re: Dynamically adding MapperExtension

2007-02-09 Thread svilen
question. Lets say I have a series of table definitions, and a series of objects linked to the tables with a bunch of mappers. First question: Is there a way to get from the table definitions in the metadata to the Mapper? For simple table==class, the link is 1:1. For

[sqlalchemy] Re: Dynamically adding MapperExtension

2007-02-09 Thread Michael Bayer
I should add that you *can* be more creative, and construct each mapper with a MapperExtension at the beginning which later can be enabled with a hello world callable. i.e. class MyExt(MapperExtension): def __init__(self): self.func = None def after_insert(self, ...):