Re: [sqlalchemy] How to define metaclass for a class that extends from sqlalchemy declarative base ?

2013-08-26 Thread Praveen
The problem with using Mixins is that you need to know the definition of columns already for creating the mixin class. What I am trying to do is more like get the definition dynamically on the fly.Take a look at this: def get_properties(tablename, map): table_inspector =

Re: [sqlalchemy] How to define metaclass for a class that extends from sqlalchemy declarative base ?

2013-08-26 Thread Praveen
Sorry, it should've been: class Enum_Sample(Base): Typo. On Mon, Aug 26, 2013 at 4:35 PM, Praveen praveen.venk...@gmail.com wrote: The problem with using Mixins is that you need to know the definition of columns already for creating the mixin class. What I am trying to do is more like get

Re: [sqlalchemy] How to define metaclass for a class that extends from sqlalchemy declarative base ?

2013-08-26 Thread Michael Bayer
On Aug 26, 2013, at 4:35 PM, Praveen praveen.venk...@gmail.com wrote: The problem with using Mixins is that you need to know the definition of columns already for creating the mixin class. What I am trying to do is more like get the definition dynamically on the fly.Take a look at this:

Re: [sqlalchemy] How to define metaclass for a class that extends from sqlalchemy declarative base ?

2013-08-26 Thread Michael Bayer
On Aug 26, 2013, at 5:16 PM, Michael Bayer mike...@zzzcomputing.com wrote: On Aug 26, 2013, at 4:35 PM, Praveen praveen.venk...@gmail.com wrote: The problem with using Mixins is that you need to know the definition of columns already for creating the mixin class. What I am trying to do

Re: [sqlalchemy] How to define metaclass for a class that extends from sqlalchemy declarative base ?

2013-08-26 Thread Michael Bayer
OK here we are, had to switch approaches due to a bug with the column reflect event, to use the aforementioned __mapper_cls__ (had the name wrong), so I think you'll see this is a pretty open-ended way to control how something maps as you're given total access to mapper() here: from sqlalchemy

Re: [sqlalchemy] How to define metaclass for a class that extends from sqlalchemy declarative base ?

2013-08-26 Thread Praveen
Does this work in sqlalchemy 0.6.1 ? On Mon, Aug 26, 2013 at 5:36 PM, Michael Bayer mike...@zzzcomputing.comwrote: OK here we are, had to switch approaches due to a bug with the column reflect event, to use the aforementioned __mapper_cls__ (had the name wrong), so I think you'll see this is

Re: [sqlalchemy] How to define metaclass for a class that extends from sqlalchemy declarative base ?

2013-08-26 Thread Praveen
I am getting ImportError for the following: from sqlalchemy.ext.declarative import DeferredReflection from sqlalchemy import event I use sqlalchemy 0.6.1. Is there any way I can make it work in 0.6.1 ? On Mon, Aug 26, 2013 at 5:38 PM, Praveen praveen.venk...@gmail.com wrote: Does this work

Re: [sqlalchemy] How to define metaclass for a class that extends from sqlalchemy declarative base ?

2013-08-26 Thread Michael Bayer
you'd need to hand-roll the deferred reflection part, there's an example in 0.7 called declarative_reflection but it might require features that aren't in 0.6. I'd not be looking to add any kind of slick/magic systems to an 0.6 app, 0.6 is very early in the curve for declarative techniques.

Re: [sqlalchemy] How to define metaclass for a class that extends from sqlalchemy declarative base ?

2013-08-26 Thread Praveen
Could you please point me to the link where I can find the example ? On Mon, Aug 26, 2013 at 5:41 PM, Michael Bayer mike...@zzzcomputing.comwrote: you'd need to hand-roll the deferred reflection part, there's an example in 0.7 called declarative_reflection but it might require features that

Re: [sqlalchemy] How to define metaclass for a class that extends from sqlalchemy declarative base ?

2013-08-26 Thread Praveen
nvm... i found it. On Mon, Aug 26, 2013 at 5:46 PM, Praveen praveen.venk...@gmail.com wrote: Could you please point me to the link where I can find the example ? On Mon, Aug 26, 2013 at 5:41 PM, Michael Bayer mike...@zzzcomputing.comwrote: you'd need to hand-roll the deferred reflection

Re: [sqlalchemy] How to define metaclass for a class that extends from sqlalchemy declarative base ?

2013-08-26 Thread Praveen
I tried your example in sqlalchemy 0.6 by manually plugging in api.py library (attached) that I got from herehttps://bitbucket.org/miracle2k/sqlalchemy/src/2d28ed97d3221a133b4b297a229deb294088affe/lib/sqlalchemy/ext/declarative/api.py?at=default . I get this error: File path\to\sample_orm.py,

Re: [sqlalchemy] How to define metaclass for a class that extends from sqlalchemy declarative base ?

2013-07-03 Thread Michael Bayer
your metaclass must derive from the DeclarativeMeta class. Also, I disagree that you need this metaclass, what you're trying to do is very easy using mixins, which are supported in version 0.6: http://docs.sqlalchemy.org/en/rel_0_6/orm/extensions/declarative.html#mixing-in-columns On Jul

[sqlalchemy] How to define metaclass for a class that extends from sqlalchemy declarative base ?

2013-07-02 Thread Ven Karri
I use: Python 2.6 and sqlalchemy 0.6.1 This is what I am trying to do: from sqlalchemy.types import ( Integer, String, Boolean ) from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class SampleMeta(type): def __new__(cls, name, bases,