7
7
from django .shortcuts import get_object_or_404
8
8
from django .template import (NodeList , TextNode , VariableNode ,
9
9
TemplateSyntaxError )
10
+ from django .template import Context
10
11
from django .template .loader import get_template
11
12
from django .template .loader_tags import (ConstantIncludeNode , ExtendsNode ,
12
13
BlockNode )
13
14
import warnings
14
- from sekizai .helpers import is_variable_extend_node
15
+ # from sekizai.helpers import is_variable_extend_node
15
16
16
17
def get_page_from_plugin_or_404 (cms_plugin ):
17
18
return get_object_or_404 (Page , placeholders = cms_plugin .placeholder )
@@ -21,9 +22,10 @@ def _extend_blocks(extend_node, blocks):
21
22
Extends the dictionary `blocks` with *new* blocks in the parent node (recursive)
22
23
"""
23
24
# we don't support variable extensions
24
- if is_variable_extend_node (extend_node ):
25
- return
26
- parent = extend_node .get_parent (None )
25
+ #if is_variable_extend_node(extend_node):
26
+ # return
27
+ context = Context ({'request' :True })
28
+ parent = extend_node .get_parent (context )
27
29
# Search for new blocks
28
30
for node in parent .nodelist .get_nodes_by_type (BlockNode ):
29
31
if not node .name in blocks :
@@ -42,21 +44,22 @@ def _extend_blocks(extend_node, blocks):
42
44
break
43
45
44
46
def _find_topmost_template (extend_node ):
45
- parent_template = extend_node .get_parent ({})
47
+ context = Context ({'request' :1 })
48
+ parent_template = extend_node .get_parent (context )
46
49
for node in parent_template .nodelist .get_nodes_by_type (ExtendsNode ):
47
50
# Their can only be one extend block in a template, otherwise django raises an exception
48
51
return _find_topmost_template (node )
49
52
# No ExtendsNode
50
- return extend_node .get_parent ({} )
53
+ return extend_node .get_parent (context )
51
54
52
55
def _extend_nodelist (extend_node ):
53
56
"""
54
57
Returns a list of placeholders found in the parent template(s) of this
55
58
ExtendsNode
56
59
"""
57
60
# we don't support variable extensions
58
- if is_variable_extend_node (extend_node ):
59
- return []
61
+ # if is_variable_extend_node(extend_node):
62
+ # return []
60
63
blocks = extend_node .blocks
61
64
_extend_blocks (extend_node , blocks )
62
65
placeholders = []
0 commit comments