Can anybody tell what I'm doing wrong

I have method with which register event (before_update, after_delete, 
before_insert) 
https://github.com/ITCase/sqlalchemy_mptt/blob/b0efead7a8ee5acc063b68ee3bfc756af4689d6e/sqlalchemy_mptt/mixins.py#L69

@classmethoddef register_tree(cls):
    event.listen(cls, "before_insert", cls.mptt_before_insert)
    event.listen(cls, "after_delete", cls.mptt_after_delete)
    event.listen(cls, "before_update", cls.mptt_before_update)


When I registered event and try to delete row (
https://github.com/ITCase/sqlalchemy_mptt/blob/b0efead7a8ee5acc063b68ee3bfc756af4689d6e/sqlalchemy_mptt/tests.py#L104
).

class Tree(Base, BaseNestedSets):
    __tablename__ = "tree"

    id = Column(Integer, primary_key=True)
Tree.register_tree()
def test_delete_node(self):
    node = self.session.query(Tree).filter(Tree.id == 4).one()
    self.session.delete(node)
    # id lft rgt lvl parent tree
    self.assertEqual([(1, 1, 16, 1, None, 1),
                      (2, 2, 5, 2, 1, 1),
                      (3, 3, 4, 3, 2, 1),
                      (7, 6, 15, 2, 1, 1),
                      (8, 7, 10, 3, 7, 1),
                      (9, 8, 9, 4, 8, 1),
                      (10, 11, 14, 3, 7, 1),
                      (11, 12, 13, 4, 10, 1)], self.result.all())

Called before_update method instead after_delete. But if I comment 
before_update event (
https://github.com/ITCase/sqlalchemy_mptt/blob/b0efead7a8ee5acc063b68ee3bfc756af4689d6e/sqlalchemy_mptt/mixins.py#L72)
 
it's work fine.

@classmethoddef register_tree(cls):
    event.listen(cls, "before_insert", cls.mptt_before_insert)
    event.listen(cls, "after_delete", cls.mptt_after_delete)
    # event.listen(cls, "before_update", cls.mptt_before_update) <-- IF comment 
this, called after_delete method. It's OK.


Build status https://travis-ci.org/ITCase/sqlalchemy_mptt/builds/23428309

What's wrong?

I asked this on 
stackoverflow.com<http://stackoverflow.com/questions/23198252/sqlalchemy-before-update-called-instead-after-delete>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to