not clear.    Sometimes, the unit of work does different things based on the 
random ordering of dictionaries, and arbitrary changes in code can trigger 
these ordering changes.  you might want to try running the script repeatedly to 
make sure these two behaviors are consistent; then try to slowly remove one by 
one things from that extra event listen; eg. have it listen on a different 
function, then remove elements from that function one by one until you find 
what triggers the difference.




On Apr 22, 2014, at 4:38 AM, uralbash <[email protected]> wrote:

> 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
> 
> @classmethod
> def 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.
> 
> @classmethod
> def 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
> 
> 
> -- 
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to