adding to a previous fix, make sure order_by is always a fully featured OrderByTuple
authorMichael Elsdoerfer <michael@elsdoerfer.info>
Fri, 27 Jun 2008 20:33:11 +0000 (22:33 +0200)
committerMichael Elsdoerfer <michael@elsdoerfer.info>
Fri, 27 Jun 2008 20:33:11 +0000 (22:33 +0200)
django_tables/tables.py
tests/test_basic.py

index 9b814fe3585e685d468a7b87ad5bfc1754d74623..064407b9834984c07a1c42ee2c8ae6bcdad6a070 100644 (file)
@@ -244,7 +244,7 @@ class BaseTable(object):
                     raise ValueError('Column name %s is invalid.' % o)\r
             self._order_by = OrderByTuple(validated_order_by)\r
         else:\r
-            self._order_by = ()\r
+            self._order_by = OrderByTuple()\r
     order_by = property(lambda s: s._order_by, _set_order_by)\r
 \r
     def __unicode__(self):\r
index a41daf2a5600c77d3c9f05761da75d64eb179615..b45ffed785ae87b70f22602c56f8e08c81c34fe6 100644 (file)
@@ -141,13 +141,17 @@ def test_sort():
         books.order_by = order\r
         assert [b['id'] for b in books.rows] == result\r
 \r
-    # None is normalized to an empty tuple, ensuring iterability; it's\r
-    # also the default value\r
+    # None is normalized to an empty order by tuple, ensuring iterability;\r
+    # it also supports all the cool methods that we offer for order_by.\r
+    # This is true for the default case...\r
     assert books.order_by == ()\r
     iter(books.order_by)\r
+    assert hasattr(books.order_by, 'reverse')\r
+    # ...as well as when explicitly set to None.\r
     books.order_by = None\r
     assert books.order_by == ()\r
     iter(books.order_by)\r
+    assert hasattr(books.order_by, 'reverse')\r
 \r
     # test various orderings\r
     test_order(('num_pages',), [1,3,2,4])\r