[sqlalchemy] Re: Get Mapper for Table

2008-04-17 Thread Koen Bok

Got it, thanks!

On Apr 16, 4:26 pm, Michael Bayer <[EMAIL PROTECTED]> wrote:
> On Apr 16, 2008, at 10:13 AM, Koen Bok wrote:
>
>
>
> > Hey all,
>
> > Before 0.4.5 I used this code to get the mapped class for a table. It
> > worked fine, but mapper_registry was made private in 0.4.5 and the
> > private function does not behave the same way for some reason. But as
> > this code is pretty nasty anyway I was wondering if there was a better
> > way to do this. If not, can anyone hint me how to make this work
> > again?
>
> from sqlalchemy.orm import mapper as _mapper
>
> my_table_registry = {}
> def mapper(cls, tbl, **kwargs):
>     my_table_registry[tbl] = cls
>     return _mapper(cls, tbl, **kwargs)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[sqlalchemy] Re: Get Mapper for Table

2008-04-16 Thread Michael Bayer


On Apr 16, 2008, at 10:13 AM, Koen Bok wrote:

>
> Hey all,
>
> Before 0.4.5 I used this code to get the mapped class for a table. It
> worked fine, but mapper_registry was made private in 0.4.5 and the
> private function does not behave the same way for some reason. But as
> this code is pretty nasty anyway I was wondering if there was a better
> way to do this. If not, can anyone hint me how to make this work
> again?
>


from sqlalchemy.orm import mapper as _mapper

my_table_registry = {}
def mapper(cls, tbl, **kwargs):
my_table_registry[tbl] = cls
return _mapper(cls, tbl, **kwargs)



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