> 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 _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 relation properties). I thought that in current SQLA it could be done also with column properties, but if not it's fine, it's not a big of a deal... just wanted to know if I can avoid this "hack".
>>> you can use that approach, it makes use of the "mapper_configured" event, which for some reason you're saying you can't use.
>> I didn't say that I can't use mapper_configured event ... I don't know how to use it :) Please take a look at:
>>
https://gist.github.com/3757273
>> With event approach (USE_EVENT=True) I have class properties, I can construct queries, etc, but table columns are not created.
>> With old monkey-patching approach (USE_EVENT=False) it works, I have properties, columns are created, etc...
> that particular test fails because the Base.metadata is being used to create the Table objects before the mappers have been configured. the mapper configuration doesn't happen until the mappings are used in some way.
>
> you can force the configuration like this:
>
> from sqlalchemy.orm import compile_mappers
> compile_mappers()
>
>
> add it above the create_all() and the script runs.
Yes, now it looks good. Thank you so much! :)