X-Git-Url: http://git.ithinksw.org/philo.git/blobdiff_plain/0d51e8dc2b15ca84b8979b94a3224b4a33f7f25e..0a98574369a343ba6ac82aeca6250fca0383e80f:/models.py diff --git a/models.py b/models.py index cb8ed07..3a06d0a 100644 --- a/models.py +++ b/models.py @@ -18,7 +18,7 @@ except ImportError: import simplejson as json from UserDict import DictMixin from templatetags.containers import ContainerNode -from django.template.loader_tags import ExtendsNode, ConstantIncludeNode, IncludeNode, BlockNode +from django.template.loader_tags import ExtendsNode, ConstantIncludeNode, IncludeNode from django.template.loader import get_template @@ -84,7 +84,7 @@ class QuerySetMapper(object, DictMixin): self.passthrough = passthrough def __getitem__(self, key): try: - return queryset.get(key__exact=key) + return self.queryset.get(key__exact=key).value except ObjectDoesNotExist: if self.passthrough: return self.passthrough.__getitem__(key) @@ -202,13 +202,13 @@ class TreeEntity(TreeModel, Entity): def attributes(self): if self.parent: return QuerySetMapper(self.attribute_set, passthrough=self.parent.attributes) - return super(Entity, self).attributes() + return super(TreeEntity, self).attributes @property def relationships(self): if self.parent: return QuerySetMapper(self.relationship_set, passthrough=self.parent.relationships) - return super(Entity, self).relationships() + return super(TreeEntity, self).relationships class Meta: abstract = True @@ -240,10 +240,12 @@ class Template(TreeModel): names = [] for node in nodelist: try: + for nodelist_name in ('nodelist', 'nodelist_loop', 'nodelist_empty', 'nodelist_true', 'nodelist_false'): + if hasattr(node, nodelist_name): + names.extend(nodelist_container_node_names(getattr(node, nodelist_name))) if isinstance(node, ContainerNode): names.append(node.name) elif isinstance(node, ExtendsNode): - names.extend(nodelist_container_node_names(node.nodelist)) extended_template = node.get_parent(Context()) if extended_template: names.extend(container_node_names(extended_template)) @@ -255,8 +257,6 @@ class Template(TreeModel): included_template = get_template(node.template_name.resolve(Context())) if included_template: names.extend(container_node_names(included_template)) - elif isinstance(node, BlockNode): - names.extend(nodelist_container_node_names(node.nodelist)) except: pass # fail for this node return names