>> What is the purpose of class_mapper? I can't find it in the .4 docs
>> for the tutorials I'm looking at, yet when I don't call it as
>>
>> https://svn.enthought.com/svn/enthought/sandbox/EnvisageSQLAlchemy/enthought/sqlalchemy/has_traits_orm.py
>>
>> notes, I get a
>>
>> AttributeError:
>> # 'ColumnProperty' object has no attribute 'key'
>
> that is an ancient bug which refers to the fact that mappers have not been
> compiled, yet an expression is doing something along the lines of
> "User.some_property == <somevalue>". The "Class.descriptor" expression
> approach was new in 0.4 and had some incompleteness.
>
> To work around it in 0.4 the most general way is to call
> compile_mappers(). class_mapper() also has the effect of invoking a
> "compile" if the mapper being returned was not yet compiled.
> class_mapper() in modern SQLAlchemy would normally only be used if
> additional configuration needs to be added to an existing mapper, given
> only a class.
Adding the class_mapper call seems to create other problems.
for db in allDataBases:
# setup the session, engine, and metadata
...
# create the tables if they don't exist
...
# grab a table out
someTable = metadata.tables['someTable']
# map it
mapper(MyObject, someTable)
# call the class mapper
class_mapper(MyObject) # has to be done after the mapper call or I
receive an Invalid Request "no mapper associated with it"
for attr in dir(myObjectInstance):
print(attr)
getattr(myObjectInstance, attr) # this now throws the following error
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?
Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---