Sure, I thought that might be something obvious. Here's runnable test which gives the above error:
import elixir from elixir import * from elixir.events import * from sqlalchemy.orm import scoped_session, sessionmaker from smisk.config import config class Project(Entity): using_options(tablename='projects') id = Field(String(100), primary_key=True) media = OneToMany('Media', cascade='all, delete') class Media(Entity): using_options(tablename='media', inheritance='multi') id = Field(String(50), primary_key=True) project = ManyToOne('Project') variants = OneToMany('MediaVariant', cascade='all, delete') attributes = OneToMany('MediaAttribute', cascade='all, delete') status = Field(String(20), nullable=True) class MediaAttribute(Entity): using_options(tablename='media_attributes') media = ManyToOne('Media', primary_key=True) attr_key = Field(String(100), primary_key=True) attr_value = Field(Unicode(255)) class MediaVariant(Entity): using_options(tablename='media_variants', inheritance='multi') id = Field(Integer, primary_key=True, autoincrement=True) original = ManyToOne('Media') class Image(Media): using_options(tablename='images', inheritance='multi') width = Field(Integer, nullable=False, default=0) height = Field(Integer, nullable=False, default=0) class ImageVariant(MediaVariant): using_options(tablename='image_variants', inheritance='multi') width = Field(Integer, nullable=False, default=0) height = Field(Integer, nullable=False, default=0) elixir.session = scoped_session(sessionmaker(autoflush=False, transactional=True)) metadata.bind = get_db_url() metadata.bind.recycle = 14400 setup_all(True) media = Media.query.filter(Media.status == u'Deleted').filter_by(project_id=u'pf2u32e').all() for m in media: m.delete() elixir.session.commit() On Friday, 24 February 2012 22:04:22 UTC+1, Michael Bayer wrote: > > > On Feb 24, 2012, at 12:37 PM, Jakob D. wrote: > > > I wrote a small script to clean up the db of old entries. > > > > So when I do obj.delete() I get this error. I also do a > session.update(obj) right before to make sure the object is present in the > session. > > > > File "deletor.py", line 95, in delete > > m.delete() > > File "/usr/lib/python2.5/site-packages/elixir/entity.py", line 963, in > delete > > return object_session(self).delete(self, *args, **kwargs) > > File "/var/lib/python-support/python2.5/sqlalchemy/orm/session.py", > line 961, in delete > > for c, m in _cascade_iterator('delete', instance): > > File "/var/lib/python-support/python2.5/sqlalchemy/orm/session.py", > line 1253, in _cascade_iterator > > for (o, m) in mapper.cascade_iterator(cascade, instance._state, > **kwargs): > > File "/var/lib/python-support/python2.5/sqlalchemy/orm/mapper.py", > line 1335, in cascade_iterator > > instance, instance_mapper, corresponding_state = iterator.next() > > File "/var/lib/python-support/python2.5/sqlalchemy/orm/properties.py", > line 451, in cascade_iterator > > instances = attributes.get_as_list(state, self.key, passive=passive) > > File "/var/lib/python-support/python2.5/sqlalchemy/orm/attributes.py", > line 1151, in get_as_list > > x = attr.get(state, passive=passive) > > File "/var/lib/python-support/python2.5/sqlalchemy/orm/attributes.py", > line 279, in get > > value = callable_() > > File "/var/lib/python-support/python2.5/sqlalchemy/orm/strategies.py", > line 466, in __call__ > > result = q.all() > > File "/var/lib/python-support/python2.5/sqlalchemy/orm/query.py", line > 878, in all > > return list(self) > > File "/var/lib/python-support/python2.5/sqlalchemy/orm/query.py", line > 1017, in iterate_instances > > context.attributes.get(('populating_mapper', ii), > _state_mapper(ii))._post_instance(context, ii) > > File "/var/lib/python-support/python2.5/sqlalchemy/orm/mapper.py", > line 1517, in _post_instance > > p(state.obj(), **kwargs) > > File "/var/lib/python-support/python2.5/sqlalchemy/orm/mapper.py", > line 1547, in post_execute > > self.populate_instance(selectcontext, instance, row, isnew=False, > instancekey=identitykey, ispostselect=True, only_load_props=only_load_props) > > File "/var/lib/python-support/python2.5/sqlalchemy/orm/mapper.py", > line 1484, in populate_instance > > (newpop, existingpop, post_proc) = > selectcontext.exec_with_path(self, prop.key, prop.create_row_processor, > selectcontext, self, row) > > File "/var/lib/python-support/python2.5/sqlalchemy/orm/query.py", line > 1703, in exec_with_path > > return fn(*args, **kwargs) > > File "/var/lib/python-support/python2.5/sqlalchemy/orm/interfaces.py", > line 532, in create_row_processor > > return > self._get_context_strategy(selectcontext).create_row_processor(selectcontext, > mapper, row) > > File "/var/lib/python-support/python2.5/sqlalchemy/orm/strategies.py", > line 75, in create_row_processor > > elif self.columns[0] in row: > > TypeError: argument of type 'NoneType' is not iterable > > > > > > Can I get a hint to what might be wrong? > > > I can give you a hint if you give us one .... a short, self-contained and > runnable test script illustrating how you're getting it to do this ? > > > On Friday, 24 February 2012 22:04:22 UTC+1, Michael Bayer wrote: > > > On Feb 24, 2012, at 12:37 PM, Jakob D. wrote: > > > I wrote a small script to clean up the db of old entries. > > > > So when I do obj.delete() I get this error. I also do a > session.update(obj) right before to make sure the object is present in the > session. > > > > File "deletor.py", line 95, in delete > > m.delete() > > File "/usr/lib/python2.5/site-packages/elixir/entity.py", line 963, in > delete > > return object_session(self).delete(self, *args, **kwargs) > > File "/var/lib/python-support/python2.5/sqlalchemy/orm/session.py", > line 961, in delete > > for c, m in _cascade_iterator('delete', instance): > > File "/var/lib/python-support/python2.5/sqlalchemy/orm/session.py", > line 1253, in _cascade_iterator > > for (o, m) in mapper.cascade_iterator(cascade, instance._state, > **kwargs): > > File "/var/lib/python-support/python2.5/sqlalchemy/orm/mapper.py", > line 1335, in cascade_iterator > > instance, instance_mapper, corresponding_state = iterator.next() > > File "/var/lib/python-support/python2.5/sqlalchemy/orm/properties.py", > line 451, in cascade_iterator > > instances = attributes.get_as_list(state, self.key, passive=passive) > > File "/var/lib/python-support/python2.5/sqlalchemy/orm/attributes.py", > line 1151, in get_as_list > > x = attr.get(state, passive=passive) > > File "/var/lib/python-support/python2.5/sqlalchemy/orm/attributes.py", > line 279, in get > > value = callable_() > > File "/var/lib/python-support/python2.5/sqlalchemy/orm/strategies.py", > line 466, in __call__ > > result = q.all() > > File "/var/lib/python-support/python2.5/sqlalchemy/orm/query.py", line > 878, in all > > return list(self) > > File "/var/lib/python-support/python2.5/sqlalchemy/orm/query.py", line > 1017, in iterate_instances > > context.attributes.get(('populating_mapper', ii), > _state_mapper(ii))._post_instance(context, ii) > > File "/var/lib/python-support/python2.5/sqlalchemy/orm/mapper.py", > line 1517, in _post_instance > > p(state.obj(), **kwargs) > > File "/var/lib/python-support/python2.5/sqlalchemy/orm/mapper.py", > line 1547, in post_execute > > self.populate_instance(selectcontext, instance, row, isnew=False, > instancekey=identitykey, ispostselect=True, only_load_props=only_load_props) > > File "/var/lib/python-support/python2.5/sqlalchemy/orm/mapper.py", > line 1484, in populate_instance > > (newpop, existingpop, post_proc) = > selectcontext.exec_with_path(self, prop.key, prop.create_row_processor, > selectcontext, self, row) > > File "/var/lib/python-support/python2.5/sqlalchemy/orm/query.py", line > 1703, in exec_with_path > > return fn(*args, **kwargs) > > File "/var/lib/python-support/python2.5/sqlalchemy/orm/interfaces.py", > line 532, in create_row_processor > > return > self._get_context_strategy(selectcontext).create_row_processor(selectcontext, > mapper, row) > > File "/var/lib/python-support/python2.5/sqlalchemy/orm/strategies.py", > line 75, in create_row_processor > > elif self.columns[0] in row: > > TypeError: argument of type 'NoneType' is not iterable > > > > > > Can I get a hint to what might be wrong? > > > I can give you a hint if you give us one .... a short, self-contained and > runnable test script illustrating how you're getting it to do this ? > > > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/yBNZuGed_h8J. 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.