MapperExtension after_update no longer called in 0.6.0b1

Issue #1577 resolved
Former user created an issue

the after_update function in my MapperExtension is no longer called in the latest trunk version of the SVN CHANGES sais its version 0.6.0b1 r6423

Comments (4)

  1. Mike Bayer repo owner
    • changed milestone to 0.6.0

    Sorry, nothing has been changed with after_update() - below is an adaptation of our unit test. Please attach a full test case which reproduces the erroneous behavior you are seeing.

    from sqlalchemy import *
    from sqlalchemy.orm import *
    
    def eq_(a, b, msg=None):
        """Assert a == b, with repr messaging on failure."""
        assert a == b, msg or "%r != %r" % (a, b)
    
    methods = [Ext(MapperExtension):
        def instrument_class(self, mapper, cls):
            methods.append('instrument_class')
            return EXT_CONTINUE
    
        def init_instance(self, mapper, class_, oldinit, instance, args, kwargs):
            methods.append('init_instance')
            return EXT_CONTINUE
    
        def init_failed(self, mapper, class_, oldinit, instance, args, kwargs):
            methods.append('init_failed')
            return EXT_CONTINUE
    
        def translate_row(self, mapper, context, row):
            methods.append('translate_row')
            return EXT_CONTINUE
    
        def create_instance(self, mapper, selectcontext, row, class_):
            methods.append('create_instance')
            return EXT_CONTINUE
    
        def reconstruct_instance(self, mapper, instance):
            methods.append('reconstruct_instance')
            return EXT_CONTINUE
    
        def append_result(self, mapper, selectcontext, row, instance, result, **flags):
            methods.append('append_result')
            return EXT_CONTINUE
    
        def populate_instance(self, mapper, selectcontext, row, instance, **flags):
            methods.append('populate_instance')
            return EXT_CONTINUE
    
        def before_insert(self, mapper, connection, instance):
            methods.append('before_insert')
            return EXT_CONTINUE
    
        def after_insert(self, mapper, connection, instance):
            methods.append('after_insert')
            return EXT_CONTINUE
    
        def before_update(self, mapper, connection, instance):
            methods.append('before_update')
            return EXT_CONTINUE
    
        def after_update(self, mapper, connection, instance):
            methods.append('after_update')
            return EXT_CONTINUE
    
        def before_delete(self, mapper, connection, instance):
            methods.append('before_delete')
            return EXT_CONTINUE
    
        def after_delete(self, mapper, connection, instance):
            methods.append('after_delete')
            return EXT_CONTINUE
    
    engine = create_engine('sqlite://')
    metadata = MetaData(engine)
    users = Table('users', metadata,
              Column('id', Integer, primary_key=True),
              Column('name', String(30), nullable=False))
    metadata.create_all()
    
    class User(object):
        def __init__(self, name):
            self.name = name
    
    mapper(User, users, extension=Ext())
    sess = create_session()
    u = User(name='u1')
    sess.add(u)
    sess.flush()
    u = sess.query(User).populate_existing().get(u.id)
    sess.expunge_all()
    u = sess.query(User).get(u.id)
    u.name = 'u1 changed'
    sess.flush()
    sess.delete(u)
    sess.flush()
    eq_(methods,
        ['instrument_class', 'init_instance', 'before_insert',
         'after_insert', 'translate_row', 'populate_instance',
         'append_result', 'translate_row', 'create_instance',
         'populate_instance', 'reconstruct_instance', 'append_result',
         'before_update', 'after_update', 'before_delete', 'after_delete'](]
    
    class))
    
  2. Former user Account Deleted

    Problem solved. I had another mapper extension which only overrides the after_XXX functions and it wasn't returning EXT_CONTINUE Sorry.

  3. Log in to comment