[sqlalchemy] Classes as model properties

2012-09-21 Thread Tefnet Developers
Hi, we are trying to migrate our old *Extension based SQLA code to new - event based. We also have class based properties that we want to keep. With old SQLA we have had to monkey-patch _as_declarative function to populate our properties. I wonder if it is possible to avoid doing it with

Re: [sqlalchemy] Classes as model properties

2012-09-21 Thread Michael Bayer
my immediate thought on that code is to replace TefProperty with a function, since you are discarding TefProperty in any case: def propInt(): return sa.Column(key, Integer) not sure how the previous Extension version of the code did this differently, this is really a class creational

Re: [sqlalchemy] Classes as model properties

2012-09-21 Thread Tefnet Developers
My example is just the shortest code I could come up with to show a problem, but in production it doesn't look like this. We're using class inheritance, metaclass features etc, so changing it to function is not an option for us :| W dniu 21.09.2012 15:59, Michael Bayer pisze: my immediate

Re: [sqlalchemy] Classes as model properties

2012-09-21 Thread Michael Bayer
using a class there which replaces itself means you've developed a custom creational pattern. A less hacky approach would be to subclass DeclarativeMeta, and just pass it to your Base: from sqlalchemy.ext.declarative import DeclarativeMeta class TefnetMeta(DeclarativeMeta): def

Re: [sqlalchemy] Classes as model properties

2012-09-21 Thread Tefnet Developers
In fact we used to use metaclass way of handling this problem, but for some unknown reason it was changed to monkey patching _as_declarative :| Couple months ago I've read your post: http://techspot.zzzeek.org/2011/05/17/magic-a-new-orm/ where there is a similar approach (classes generate

Re: [sqlalchemy] Classes as model properties

2012-09-21 Thread Michael Bayer
On Sep 21, 2012, at 10:57 AM, Tefnet Developers wrote: In fact we used to use metaclass way of handling this problem, but for some unknown reason it was changed to monkey patching _as_declarative :| Couple months ago I've read your post:

Re: [sqlalchemy] Classes as model properties

2012-09-21 Thread Tefnet Developers
W dniu 21.09.2012 17:19, Michael Bayer pisze: On Sep 21, 2012, at 10:57 AM, Tefnet Developers wrote: In fact we used to use metaclass way of handling this problem, but for some unknown reason it was changed to monkey patching _as_declarative :| Couple months ago I've read your post:

Re: [sqlalchemy] Classes as model properties

2012-09-21 Thread Michael Bayer
On Sep 21, 2012, at 11:31 AM, Tefnet Developers wrote: W dniu 21.09.2012 17:19, Michael Bayer pisze: On Sep 21, 2012, at 10:57 AM, Tefnet Developers wrote: In fact we used to use metaclass way of handling this problem, but for some unknown reason it was changed to monkey patching

Re: [sqlalchemy] Classes as model properties

2012-09-21 Thread Tefnet Developers
W dniu 21.09.2012 17:58, Michael Bayer pisze: On Sep 21, 2012, at 11:31 AM, Tefnet Developers wrote: W dniu 21.09.2012 17:19, Michael Bayer pisze: On Sep 21, 2012, at 10:57 AM, Tefnet Developers wrote: In fact we used to use metaclass way of handling this problem, but for some unknown