-node_create = django.dispatch.Signal(providing_args=['instance'])\r
-node_edit = django.dispatch.Signal(providing_args=['instance'])\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
+\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