yeah im not sure if i can "fix" that behavior, your call to
Person.c.uid is compiling the Person mapper before the Contract mapper
has been created.   therefore when you call Person.get(), no mappers
compile and Contract remains uncompiled, and your
"contracts_responsible" attribute remains uninitialized.

so you need to either not reference Person.c ahead of time, or call
Contract.mapper.compile(), or use 0.3.4 and call "compile_mappers()"
to compile all mappers.

On Feb 6, 6:53 am, Marco Mariani <[EMAIL PROTECTED]> wrote:
> I'm working inside TurboGears, autoload everything.
> Tested with 0.3.3 and Trunk.
>
> I find this strange behaviour: when I declare a relation between a
> Person and a Contract:
>
> assign_mapper(context, Contract, tbl['contracts'], properties = {
>     'responsible' : relation(Person,
>                               backref='contracts_responsible',
>                               # ambiguous... do an explicit join
>
> primaryjoin=(tbl['contracts'].c.uid_responsible==Person.c.uid)),
>    [...]
> )
>
> Now, if I start the console, then run...
>
> john = Person.get('johndoe')
> john.contracts_responsible
>
> gives me
>
> AttributeError: 'Person' object has no attribute 'contracts_responsabile'
>
> _but_ the very moment I load any contract:
>
> cont = Contract.get('somecode')
>
> _then_ john.contracts_responsible starts working and returns the list of
> contracts that john is responsible for.
>
> The same happens with any backref... i'm puzzled  O_o
>
> If this is not a known feature/bug, I can try and reproduce it in a
> standalone project
>
> Thanks


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

Reply via email to