]> git.openstreetmap.org Git - osqa.git/commitdiff
One more 1.2 compatibility fix.
authorhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Wed, 19 May 2010 23:46:35 +0000 (23:46 +0000)
committerhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Wed, 19 May 2010 23:46:35 +0000 (23:46 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@308 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/models/node.py

index cf69233334823d03b8d66ffc78e4c1e4f2672fd4..4f6b6d105e921fb7ce66e0e04f23aa9d2aeda976 100644 (file)
@@ -78,25 +78,27 @@ class NodeMetaClass(BaseMetaClass):
         Node.add_to_class(name, property(parent))\r
 \r
 \r
+class NodeQuerySet(CachedQuerySet):\r
+    def get(self, *args, **kwargs):\r
+        node = super(NodeQuerySet, self).get(*args, **kwargs)\r
+        cls = NodeMetaClass.types.get(node.node_type, None)\r
+\r
+        if cls and (node.__class__ is not cls):\r
+            return node.leaf\r
+        return node\r
+\r
+\r
 class NodeManager(CachedManager):\r
     use_for_related_fields = True\r
 \r
     def get_query_set(self):\r
-        qs = super(NodeManager, self).get_query_set()\r
+        qs = NodeQuerySet(self.model)\r
 \r
         if self.model is not Node:\r
             return qs.filter(node_type=self.model.get_type())\r
         else:\r
             return qs\r
 \r
-    def get(self, *args, **kwargs):\r
-        node = super(NodeManager, self).get(*args, **kwargs)\r
-        cls = NodeMetaClass.types.get(node.node_type, None)\r
-\r
-        if cls and node.__class__ is not cls:\r
-            return node.leaf\r
-        return node\r
-\r
     def get_for_types(self, types, *args, **kwargs):\r
         kwargs['node_type__in'] = [t.get_type() for t in types]\r
         return self.get(*args, **kwargs)\r