is_descendant_of error when moving nodes

Issue #43 invalid
Rob Hudson
created an issue

Copy/Paste error:

{{{ Traceback: File "/opt/virtualenvs/eap/lib/python2.6/site-packages/django/core/handlers/" in get_response 100. response = callback(request, callback_args, callback_kwargs) File "/opt/virtualenvs/eap/lib/python2.6/site-packages/django/contrib/admin/" in wrapper 265. return self.admin_site.admin_view(view)(*args, kwargs) File "/opt/virtualenvs/eap/lib/python2.6/site-packages/django/utils/" in _wrapped_view 76. response = view_func(request, args, kwargs) File "/opt/virtualenvs/eap/lib/python2.6/site-packages/django/views/decorators/" in _wrapped_view_func 78. response = view_func(request, *args, kwargs) File "/opt/virtualenvs/eap/lib/python2.6/site-packages/django/contrib/admin/" in inner 190. return view(request, args, kwargs) File "/opt/virtualenvs/eap/lib/python2.6/site-packages/django/utils/" in _wrapper 21. return decorator(bound_func)(*args, kwargs) File "/opt/virtualenvs/eap/lib/python2.6/site-packages/django/utils/" in _wrapped_view 76. response = view_func(request, args, kwargs) File "/opt/virtualenvs/eap/lib/python2.6/site-packages/django/utils/" in bound_func 17. return func(self, *args2, kwargs2) File "/opt/virtualenvs/eap/lib/python2.6/site-packages/django/db/" in _commit_on_success 299. res = func(args, *kw) File "/opt/virtualenvs/eap/lib/python2.6/site-packages/django/contrib/admin/" in change_view 903. new_object = self.save_form(request, form, change=True) File "/opt/virtualenvs/eap/lib/python2.6/site-packages/django/contrib/admin/" in save_form 617. return File "/opt/virtualenvs/eap/src/django-treebeard-tip/treebeard/" in save 151. self.instance.move(reference_node, pos=position_type) File "/opt/virtualenvs/eap/src/django-treebeard-tip/treebeard/" in move 307. if target.is_descendant_of(self):

Exception Type: AttributeError at /admin/keiko/modulepage/14/ Exception Value: 'NoneType' object has no attribute 'is_descendant_of' }}}

The 2nd to last stack has these local variables:

{{{ commit: False position_type: u'first-child' reference_node: <ModulePage: m-1000 -> m-1000> reference_node_id: 13 self: <django.forms.models.ModulePageForm object at 0x555557c5ca90> }}}

The last stack has these local variables:

{{{ cls: <class 'web.keiko.models.ModulePage'> parent: None pos: 'first-sibling' self: <ModulePage: m-1000 -> m-1005> target: None }}}

It looks like an edge case when trying to move a sibling into the root (top) node?

Comments (5)

  1. Gustavo Picón repo owner
    • changed status to open


    Your tree is inconsistent.

    Could you please send me this for analysis?

    [(, x.tree_id, x.lft, x.rgt, x.depth) for x in web.keiko.models.ModulePage.objects.all()]

    Basically what is hapenning in is that the target node is NOT a leaf (rgt-lft>1), but then there are no child nodes (lft<>rgt in the interval and depth=depth+1). We need find_problems/fix_tree for NS nodes too.

  2. LeoC

    I encountered a similar issue too. Not sure if it is same as the above issue. But I see the same error message. I did a nodeA.move(nodeB,pos='last-child') The issue only happens periodically. Especially when I move many nodes in the same script. Every time it happens, len(nodeB.get_children()) is 0 but nodeB.is_leaf() is false. The issue no longer happens if if I do a and after each move(). I guess it is something to do with db transactions.

  3. LeoC

    In, MP_Node.move()

    The last line is transaction.commit_unless_managed() That function is deprecated in django 1.7 Would that be the issue?

  4. Log in to comment