jdornak pushed to python-django-sekizai (f22). "django 1.8 compatibility"
notifications at fedoraproject.org
notifications at fedoraproject.org
Mon Jun 8 18:15:32 UTC 2015
From 346cc3d2d6f3f36a62377af68ef84382b060ba73 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jakub=20Dor=C5=88=C3=A1k?= <jdornak at redhat.com>
Date: Mon, 8 Jun 2015 20:12:07 +0200
Subject: django 1.8 compatibility
diff --git a/django-1.8-compatibility.patch b/django-1.8-compatibility.patch
new file mode 100644
index 0000000..a72b936
--- /dev/null
+++ b/django-1.8-compatibility.patch
@@ -0,0 +1,115 @@
+diff --git a/sekizai/helpers.py b/sekizai/helpers.py
+index aa037e6..ae9c4f1 100644
+--- a/sekizai/helpers.py
++++ b/sekizai/helpers.py
+@@ -1,9 +1,28 @@
+ # -*- coding: utf-8 -*-
++from collections import namedtuple
++
+ from django.conf import settings
+-from django.template import VariableNode, Variable
++from django.template.base import VariableNode, Variable, Template
+ from django.template.loader import get_template
+ from django.template.loader_tags import BlockNode, ExtendsNode
+
++try:
++ from django.template import engines
++except ImportError:
++ engines = None
++
++if engines is not None:
++ FAKE_CONTEXT = namedtuple('Context', 'engine')(engines.all()[0])
++else:
++ FAKE_CONTEXT = {}
++
++
++def _get_nodelist(tpl):
++ if isinstance(tpl, Template):
++ return tpl.nodelist
++ else:
++ return tpl.template.nodelist
++
+
+ def is_variable_extend_node(node):
+ if hasattr(node, 'parent_name_expr') and node.parent_name_expr:
+@@ -17,14 +36,15 @@ def is_variable_extend_node(node):
+
+ def _extend_blocks(extend_node, blocks):
+ """
+- Extends the dictionary `blocks` with *new* blocks in the parent node (recursive)
++ 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)
++ parent = extend_node.get_parent(FAKE_CONTEXT)
+ # Search for new blocks
+- for node in parent.nodelist.get_nodes_by_type(BlockNode):
++ for node in _get_nodelist(parent).get_nodes_by_type(BlockNode):
+ if node.name not in blocks:
+ blocks[node.name] = node
+ else:
+@@ -37,7 +57,7 @@ def _extend_blocks(extend_node, blocks):
+ block = block.super
+ block.super = node
+ # search for further ExtendsNodes
+- for node in parent.nodelist.get_nodes_by_type(ExtendsNode):
++ for node in _get_nodelist(parent).get_nodes_by_type(ExtendsNode):
+ _extend_blocks(node, blocks)
+ break
+
+@@ -55,29 +75,25 @@ def _extend_nodelist(extend_node):
+ found = []
+
+ for block in blocks.values():
+- found += _scan_namespaces(block.nodelist, block, blocks.keys())
++ found += _scan_namespaces(block.nodelist, block)
+
+- parent_template = extend_node.get_parent({})
++ parent_template = extend_node.get_parent(FAKE_CONTEXT)
+ # if this is the topmost template, check for namespaces outside of blocks
+- if not parent_template.nodelist.get_nodes_by_type(ExtendsNode):
++ if not _get_nodelist(parent_template).get_nodes_by_type(ExtendsNode):
+ found += _scan_namespaces(
+- parent_template.nodelist,
+- None,
+- blocks.keys()
++ _get_nodelist(parent_template),
++ None
+ )
+ else:
+ found += _scan_namespaces(
+- parent_template.nodelist,
+- extend_node,
+- blocks.keys()
++ _get_nodelist(parent_template),
++ extend_node
+ )
+ return found
+
+
+-def _scan_namespaces(nodelist, current_block=None, ignore_blocks=None):
++def _scan_namespaces(nodelist, current_block=None):
+ from sekizai.templatetags.sekizai_tags import RenderBlock
+- if ignore_blocks is None:
+- ignore_blocks = []
+ found = []
+
+ for node in nodelist:
+@@ -102,7 +118,7 @@ def _scan_namespaces(nodelist, current_block=None, ignore_blocks=None):
+
+ def get_namespaces(template):
+ compiled_template = get_template(template)
+- return _scan_namespaces(compiled_template.nodelist)
++ return _scan_namespaces(_get_nodelist(compiled_template))
+
+
+ def validate_template(template, namespaces):
+@@ -155,5 +171,3 @@ class Watcher(object):
+ ]
+ changes[key] = new_values
+ return changes
+-
+-
diff --git a/python-django-sekizai.spec b/python-django-sekizai.spec
index 4d3a19e..2b893d6 100644
--- a/python-django-sekizai.spec
+++ b/python-django-sekizai.spec
@@ -19,6 +19,7 @@ Group: Development/Libraries
License: BSD
URL: http://django-sekizai.readthedocs.org/
Source0: https://pypi.python.org/packages/source/d/%{pkgname}/%{pkgname}-%{version}.tar.gz
+Patch0: django-1.8-compatibility.patch
BuildArch: noarch
@@ -82,6 +83,7 @@ This package contains the documentation for %{pkgname}.
%prep
%setup -q -n %{pkgname}-%{version}
+%patch0 -p 1
%if 0%{?with_python3}
cp -a . %{py3dir}
--
cgit v0.10.2
http://pkgs.fedoraproject.org/cgit/python-django-sekizai.git/commit/?h=f22&id=346cc3d2d6f3f36a62377af68ef84382b060ba73
More information about the scm-commits
mailing list