Ok, so the problem might be because the first test fails while doing Session.clear():
Traceback (most recent call last): File ".../tests/__init__.py", line 35, in tearDown Session.clear() File "/usr/lib/python2.5/site-packages/SQLAlchemy-0.4.6-py2.5.egg/ sqlalchemy/orm/scoping.py", line 98, in do return getattr(self.registry(), name)(*args, **kwargs) File "/usr/lib/python2.5/site-packages/SQLAlchemy-0.4.6-py2.5.egg/ sqlalchemy/orm/session.py", line 668, in clear self._unattach(instance) File "/usr/lib/python2.5/site-packages/SQLAlchemy-0.4.6-py2.5.egg/ sqlalchemy/orm/session.py", line 1141, in _unattach if instance._sa_session_id == self.hash_key: AttributeError: 'User' object has no attribute '_sa_session_id' The background for this situation is in the first post of this thread: create_instance simply returns User() object. However, if instead of that I return EXT_CONTINUE - everything works fine. So maybe there's something missing in my create_instance definition? On 4 Rugp, 18:11, Michael Bayer <[EMAIL PROTECTED]> wrote: > On Aug 4, 2008, at 4:29 AM, naktinis wrote: > > > > > User.__init__() only contains attribute assignments like: > > def __init__(self, **kw): > > self.name = kw.get('name', u'') > > ... > > self.email = kw.get('email', u'') > > > Nothing more. What details would be more helpful? > > something else is going on. you'd have to provide us with a complete > test case which reproduces the issue. > > > > > On 2 Rugp, 20:35, Michael Bayer <[EMAIL PROTECTED]> wrote: > >> On Aug 2, 7:46 am, naktinis <[EMAIL PROTECTED]> wrote: > > >>> Hi, > >>> I have created an ExtensionMapper: > > >>> class UserMapperExtension(MapperExtension): > >>> defcreate_instance(self, mapper, selectcontext, row, class_): > >>> return User() > > >>> Session.mapper(User, user_table, extension=UserMapperExtension()) > > >>> At first everything seemed to work fine, but when I runned my unit > >>> tests (nosetests) I get errors (if I turn off the extension they are > >>> gone). After every: > >>> super(UserTestCase, self).setUp() > >>> Session.flush() > > >>> I get: > >>> ConcurrentModificationError: Updated rowcount 0 does not match > >>> number > >>> of objects updated 1 > > >>> Or sometimes: > >>> IntegrityError: (IntegrityError) (1452, 'Cannot add or update a > >>> child > >>> row: a foreign key constraint fails ... CONSTRAINT > >>> 'some_constraint' > >>> FOREIGN KEY (`user_id`) REFERENCES `user` (`id`))') u'UPDATE other > >>> SET > >>> user_id=%s WHERE other.id = %s' > > >>> which were not present before adding the ExtensionMapper. > > >>> What could be the problem? > > >> what kind of behavior fires off in User.__init__() ? other than > >> that > >> you'd have to provide a more concrete example. > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---