Minor tweaks to the sobol results templates.
[philo.git] / models / pages.py
index b7b43c5..2221ee4 100644 (file)
@@ -18,16 +18,24 @@ from philo.signals import page_about_to_render_to_string, page_finished_renderin
 
 
 class LazyContainerFinder(object):
-       def __init__(self, nodes):
+       def __init__(self, nodes, extends=False):
                self.nodes = nodes
                self.initialized = False
                self.contentlet_specs = set()
                self.contentreference_specs = SortedDict()
                self.blocks = {}
                self.block_super = False
+               self.extends = extends
        
        def process(self, nodelist):
                for node in nodelist:
+                       if self.extends:
+                               if isinstance(node, BlockNode):
+                                       self.blocks[node.name] = block = LazyContainerFinder(node.nodelist)
+                                       block.initialize()
+                                       self.blocks.update(block.blocks)
+                               continue
+                       
                        if isinstance(node, ContainerNode):
                                if not node.references:
                                        self.contentlet_specs.add(node.name)
@@ -36,15 +44,6 @@ class LazyContainerFinder(object):
                                                self.contentreference_specs[node.name] = node.references
                                continue
                        
-                       if isinstance(node, BlockNode):
-                               self.blocks[node.name] = block = LazyContainerFinder(node.nodelist)
-                               block.initialize()
-                               self.blocks.update(block.blocks)
-                               continue
-                       
-                       if isinstance(node, ExtendsNode):
-                               continue
-                       
                        if isinstance(node, VariableNode):
                                if node.filter_expression.var.lookups == (u'block', u'super'):
                                        self.block_super = True
@@ -97,7 +96,7 @@ class Template(TreeModel):
                        
                        if extends:
                                if extends.nodelist:
-                                       nodelists.append(LazyContainerFinder(extends.nodelist))
+                                       nodelists.append(LazyContainerFinder(extends.nodelist, extends=True))
                                loaded_template = getattr(extends, LOADED_TEMPLATE_ATTR)
                                nodelists.extend(build_extension_tree(loaded_template.nodelist))
                        else:
@@ -172,6 +171,9 @@ class Page(View):
                return self.title
        
        def clean_fields(self, exclude=None):
+               if exclude is None:
+                       exclude = []
+               
                try:
                        super(Page, self).clean_fields(exclude)
                except ValidationError, e: