sehughes / django-treebeard

Automatically exported from code.google.com/p/django-treebeard
Apache License 2.0
0 stars 0 forks source link

MP_Node.fix_tree destroys all data #13

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This is the output I get on the Python console. I've just one newly created 
object in the database 
and I do MP_Node.fix_tree() which fails to re-import the dumped data (because 
it contains fkeys 
not just plain attributes) after which the table is empty.

ContentNode is the class that inherits from MP_Node. treebeard version 1.1.

In [1]: ContentNode.get_tree()
Out[1]: [<ContentNode: en>]

In [2]: ContentNode.fix_tree()
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (406, 0))

--------------------------------------------------------------------------
-
ValueError                                Traceback (most recent call last)

/Users/erik/projects/estonica/src/<ipython console> in <module>()

/Users/erik/projects/estonica/lib/python2.5/site-packages/treebeard/mp_tree.pyc 
in 
fix_tree(cls)
    465         dump = cls.dump_bulk(None, True)
    466         cls.objects.all().delete()
--> 467         cls.load_bulk(dump, None, True)
    468 
    469 

/Users/erik/projects/estonica/lib/python2.5/site-packages/treebeard/models.pyc 
in 
load_bulk(cls, bulk_data, parent, keep_ids)
    154                 node_obj = parent.add_child(**node_data)
    155             else:
--> 156                 node_obj = cls.add_root(**node_data)
    157             added.append(node_obj.id)
    158             if 'children' in node_struct:

/Users/erik/projects/estonica/lib/python2.5/site-packages/treebeard/mp_tree.pyc 
in 
add_root(cls, **kwargs)
    321             newpath = cls._get_path(None, 1, 1)
    322         # creating the new object
--> 323         newobj = cls(**kwargs)
    324         newobj.depth = 1
    325         newobj.path = newpath

/Users/erik/python-packages/django/django/db/models/base.pyc in __init__(self, 
*args, 
**kwargs)
    309                 # "user_id") so that the object gets properly cached (and type
    310                 # checked) by the RelatedObjectDescriptor.
--> 311                 setattr(self, field.name, rel_obj)
    312             else:
    313                 setattr(self, field.attname, val)

/Users/erik/python-packages/django/django/db/models/fields/related.pyc in 
__set__(self, 
instance, value)
    270             raise ValueError('Cannot assign "%r": "%s.%s" must be a "%s" instance.' %
    271                                 (value, instance._meta.object_name,
--> 272                                  self.field.name, 
self.field.rel.to._meta.object_name))
    273 
    274         # Set the value of the related field

ValueError: Cannot assign "15": "ContentNode.content_type" must be a 
"ContentType" instance.

In [3]: ContentNode.get_tree()
Out[3]: []

Original issue reported on code.google.com by eallik on 26 May 2009 at 5:56

GoogleCodeExporter commented 9 years ago
eallik:

This is a known problem with the implementation of MP_Node.fix_tree(), and in 
fact it's in the documentation. I'm 
updating the docs to put this in a warning instead of a note to make it more 
visible.

Original comment by gpicon on 14 Jun 2009 at 12:38

GoogleCodeExporter commented 9 years ago
This issue was closed by r95.

Original comment by gpicon on 14 Jun 2009 at 12:41

GoogleCodeExporter commented 9 years ago
writing a CORRECT MP_Node.fix_tree()  is an interesting problem, patches are 
welcome :)

Original comment by gpicon on 14 Jun 2009 at 12:43

GoogleCodeExporter commented 9 years ago
This issue was closed by revision dbb98a5150.

Original comment by gpicon on 14 Oct 2009 at 3:47