Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

The correct ordering in NS/MP trees is now enforced in the queryset.

  • Loading branch information...
commit 03b2c3e6e2b56a6abc6dc5fd250c72d3244dbce4 1 parent 2b1220e
@tabo authored
Showing with 11 additions and 40 deletions.
  1. +1 −0  CHANGES
  2. +8 −0 UPDATING
  3. +1 −20 treebeard/mp_tree.py
  4. +1 −20 treebeard/ns_tree.py
View
1  CHANGES
@@ -4,6 +4,7 @@ Release tip (??? ??, 2010)
* Added raw id fields support in the admin
* Fixed setup.py to make it work in 2.4 again
+* The correct ordering in NS/MP trees is now enforced in the queryset.
Release 1.52 (Dec 18, 2009)
View
8 UPDATING
@@ -6,3 +6,11 @@ This file documents problems you may encounter when upgrading django-treebeard
Cleaned __init__.py, if you need Node you'll have to call it from it's
original location (treebeard.models.Node instead of treebeard.Node). Also
exceptions have been moved to treebeard.exceptions.
+
+
+
+20100316:
+
+ Queryset ordering in NS/MP trees is now enforced by the library. Previous
+ ordering settings in META no longer work.
+
View
21 treebeard/mp_tree.py
@@ -134,7 +134,7 @@ def get_query_set(self):
"""
Sets the custom queryset as the default.
"""
- return MP_NodeQuerySet(self.model)
+ return MP_NodeQuerySet(self.model).order_by('path')
class MP_Node(Node):
@@ -268,18 +268,6 @@ class TestNodeSortedAutoNow(MP_Node):
4. Restore your backup using :meth:`load_bulk` with
``keep_ids=True`` to keep the same primary keys you had.
- .. warning::
-
- Be very careful if you add a ``Meta`` class in your
- :class:`mp_tree.MP_Node` subclass.
- You must add an ordering attribute with a single element on it::
-
- class Meta:
- ordering = ['path']
-
- If you don't, the tree won't work, since :class:`mp_tree.MP_Node`
- completely depends on this attribute.
-
Example::
class SortedNode(MP_Node):
@@ -1195,10 +1183,3 @@ class Meta:
Abstract model.
"""
abstract = True
- # By changing the ordering, assume that lots of things will break,
- # at least you'll want to check the first/last/prev/next methods.
- # This ordering assumes you want something... TREEISH
- # PROTIP: don't change this
- # PROTIP2: Set the ordering property again if you add a Meta in
- # your subclass
- ordering = ['path']
View
21 treebeard/ns_tree.py
@@ -100,7 +100,7 @@ def get_query_set(self):
"""
Sets the custom queryset as the default.
"""
- return NS_NodeQuerySet(self.model)
+ return NS_NodeQuerySet(self.model).order_by('tree_id', 'lft')
class NS_Node(Node):
@@ -132,18 +132,6 @@ class NS_Node(Node):
.. attribute:: tree_id
``PositiveIntegerField``
-
- .. warning::
-
- Be very careful if you add a ``Meta`` class in your
- :class:`ns_tree.NS_Node` subclass.
- You must add an ordering attribute with two elements on it::
-
- class Meta:
- ordering = ['tree_id', 'lft']
-
- If you don't, the tree won't work, since :class:`ns_tree.NS_Node`
- completely depends on this attribute.
"""
node_order_by = []
@@ -738,10 +726,3 @@ class Meta:
Abstract model.
"""
abstract = True
- # By changing the ordering, assume that lots of things will break,
- # at least you'll want to check the first/last/prev/next methods.
- # This ordering assumes you want something... TREEISH
- # PROTIP: don't change this
- # PROTIP2: Set the ordering property again if you add a Meta in
- # your subclass
- ordering = ['tree_id', 'lft']
Please sign in to comment.
Something went wrong with that request. Please try again.