Skip to content

Commit

Permalink
Merge branch 'pjax' into apsl
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernardo Cabezas committed Aug 21, 2012
2 parents a052f59 + b07afea commit e08f77b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions cms/utils/plugins.py
Expand Up @@ -7,11 +7,12 @@
from django.shortcuts import get_object_or_404
from django.template import (NodeList, TextNode, VariableNode,
TemplateSyntaxError)
from django.template import Context
from django.template.loader import get_template
from django.template.loader_tags import (ConstantIncludeNode, ExtendsNode,
BlockNode)
import warnings
from sekizai.helpers import is_variable_extend_node
#from sekizai.helpers import is_variable_extend_node

def get_page_from_plugin_or_404(cms_plugin):
return get_object_or_404(Page, placeholders=cms_plugin.placeholder)
Expand All @@ -21,9 +22,10 @@ def _extend_blocks(extend_node, blocks):
Extends the dictionary `blocks` with *new* blocks in the parent node (recursive)
"""
# we don't support variable extensions
if is_variable_extend_node(extend_node):
return
parent = extend_node.get_parent(None)
#if is_variable_extend_node(extend_node):
# return
context = Context({'request':True})
parent = extend_node.get_parent(context)
# Search for new blocks
for node in parent.nodelist.get_nodes_by_type(BlockNode):
if not node.name in blocks:
Expand All @@ -42,21 +44,22 @@ def _extend_blocks(extend_node, blocks):
break

def _find_topmost_template(extend_node):
parent_template = extend_node.get_parent({})
context = Context({'request':1})
parent_template = extend_node.get_parent(context)
for node in parent_template.nodelist.get_nodes_by_type(ExtendsNode):
# Their can only be one extend block in a template, otherwise django raises an exception
return _find_topmost_template(node)
# No ExtendsNode
return extend_node.get_parent({})
return extend_node.get_parent(context)

def _extend_nodelist(extend_node):
"""
Returns a list of placeholders found in the parent template(s) of this
ExtendsNode
"""
# we don't support variable extensions
if is_variable_extend_node(extend_node):
return []
#if is_variable_extend_node(extend_node):
# return []
blocks = extend_node.blocks
_extend_blocks(extend_node, blocks)
placeholders = []
Expand Down

0 comments on commit e08f77b

Please sign in to comment.