On Oct 20, 2009, at 5:50 PM, Josh Stratton wrote:

>
>>> AttributeError: 'MyObject' object has no attribute '_state'
>>>
>>> I don't see any _state printed out.  The only additional attribute I
>>> see is the 'c' variable, where pull tables from.  What is causing  
>>> this
>>> _state thing to appear?  Do I need to call class_mapper after each
>>> mapper only only once after any mapper?
>>
>> this error indicates that an instance of "MyObject" was instantiated
>> before mappers were created.   In your example you're accessing
>> "myObjectInstance" however I don't see where that's being  
>> instantiated, so
>> the fact that the mapper is set up just above would be the cause.
>>
>> the configuration of mappers (note that this does not include the
>> configuration of engines or sessions - just mappers) should occur at
>> application start time as closely as possible to the point at which  
>> the
>> classes themselves have been defined.    This is one reason the
>> "declarative" extension has been popular, since it performs both at  
>> the
>> same time by definition.
>
> Okay, that seemed to work.  Thanks.  A mapper() call followed by a
> class_mapper() call for each database did the trick.

There really only needs to be one mapper() call, per class, and that's  
it.  different databases aren't really involved here unless you're  
creating new classes each time, or something.    class_mapper()  
doesn't have to be involved at all.     if you are really having  
troubles with mappers compiling, at most you'd need one call to  
compile_mappers() after all your classes are declared, and thats it.    
But you shouldn't even need that, though im allowing for 0.4 having  
some glitches in that area.

you can keep doing what youre doing of course but there's still some  
weirdness in how you're setting things up if you truly need to call  
the compilation step multiple times.





>
> Josh
>
> >


--~--~---------~--~----~------------~-------~--~----~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to