[sqlalchemy] Polymorphic write - 'InstanceState' object has no attribute 'manager'

1,015 views
Skip to first unread message

andrew cooke

unread,
May 7, 2010, 9:49:44 AM5/7/10
to sqlalchemy

Hi,

This trace is from some code that is loading a lot of objects (and
which usually does so with no problems). I don't have more details
yet (it will be quite some work to find out exactly what data is
causing the error), but it does use joined table inheritance. Does
anyone have any idea what the cause might be just from the trace?

SQLAlchemy 0.5.8 with Python 2.5 on Linux.

Thanks,
Andrew

File "/usr/local/home/andrewc/tngb3/repository-lib/src/kpi/load/
manage/statio\
ns.py", line 170, in _zero
loader.commit()
File "/usr/local/home/andrewc/tngb3/repository-lib/src/kpi/load/load/
loader.p\
y", line 169, in commit
self.__load_data(entity_map, time_series_map, metric_map)
File "/usr/local/home/andrewc/tngb3/repository-lib/src/kpi/load/load/
loader.p\
y", line 291, in __load_data
self.__session.flush()
File "/usr/local/home/andrewc/SQLAlchemy-0.5.8/build/lib/sqlalchemy/
orm/sessi\
on.py", line 1354, in flush
self._flush(objects)
File "/usr/local/home/andrewc/SQLAlchemy-0.5.8/build/lib/sqlalchemy/
orm/sessi\
on.py", line 1432, in _flush
flush_context.execute()
File "/usr/local/home/andrewc/SQLAlchemy-0.5.8/build/lib/sqlalchemy/
orm/unito\
fwork.py", line 261, in execute
UOWExecutor().execute(self, tasks)
File "/usr/local/home/andrewc/SQLAlchemy-0.5.8/build/lib/sqlalchemy/
orm/unito\
fwork.py", line 753, in execute
self.execute_save_steps(trans, task)
File "/usr/local/home/andrewc/SQLAlchemy-0.5.8/build/lib/sqlalchemy/
orm/unito\
fwork.py", line 768, in execute_save_steps
self.save_objects(trans, task)
File "/usr/local/home/andrewc/SQLAlchemy-0.5.8/build/lib/sqlalchemy/
orm/unito\
fwork.py", line 759, in save_objects
task.mapper._save_obj(task.polymorphic_tosave_objects, trans)
File "/usr/local/home/andrewc/SQLAlchemy-0.5.8/build/lib/sqlalchemy/
orm/mappe\
r.py", line 1434, in _save_obj
if mapper._get_state_attr_by_column(state, col) is None and
len(primary_key\
) > i:
File "/usr/local/home/andrewc/SQLAlchemy-0.5.8/build/lib/sqlalchemy/
orm/mappe\
r.py", line 1111, in _get_state_attr_by_column
return self._get_col_to_prop(column).getattr(state, column)
File "/usr/local/home/andrewc/SQLAlchemy-0.5.8/build/lib/sqlalchemy/
orm/prope\
rties.py", line 99, in getattr
return state.get_impl(self.key).get(state, state.dict)
File "/usr/local/home/andrewc/SQLAlchemy-0.5.8/build/lib/sqlalchemy/
orm/state\
.py", line 92, in get_impl
return self.manager.get_impl(key)
AttributeError: 'InstanceState' object has no attribute 'manager'

--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To post to this group, send email to sqlal...@googlegroups.com.
To unsubscribe from this group, send email to sqlalchemy+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.

Michael Bayer

unread,
May 7, 2010, 9:56:07 AM5/7/10
to sqlal...@googlegroups.com
this looks like some kind of serialization issue. are you deserializing instances before mappers have been compiled ? if you upgrade to 0.6, this will raise an error immediately at the point at which it occurs.

andrew cooke

unread,
May 7, 2010, 10:14:30 AM5/7/10
to sqlalchemy

As far as I know, I'm doing nothing that complex. I am creating a
pile of mapped objects in Python and then dumping them to the
database. The most likely cause is that a field is None, or of the
incorrect type in some way, I would have guessed.

Andrew

On May 7, 9:56 am, Michael Bayer <mike...@zzzcomputing.com> wrote:
> this looks like some kind of serialization issue.   are you deserializing instances before mappers have been compiled ?    if you upgrade to 0.6, this will raise an error immediately at the point at which it occurs.

Michael Bayer

unread,
May 7, 2010, 10:39:06 AM5/7/10
to sqlal...@googlegroups.com
"manager" is an attribute on InstanceState that is set at construction time, and is never changed thereafter. Looking at your error more closely, its not that "manager" is None, its not even present. That can only happen if something del'ed the "manager" attribute, the InstanceState somehow went through some failed deserialization process, or some gc-related activity had occurred involving that object. I'm not aware of any simple way to produce that effect. it certainly has nothing to do with the specifics of your mappings.
Reply all
Reply to author
Forward
0 new messages