From 9c5fe2012a14bf1c840e304b1bd1d9f72fffba6a Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Thu, 16 Apr 2015 15:17:07 +0200 Subject: [PATCH] v. 0.2.4: * Django 1.8 compatibility. * Remove private headers from response. * Python-3 compatible get_version. --- CHANGELOG.md | 9 +++++++++ README.md | 2 +- setup.cfg | 3 +++ setup.py | 6 +++--- ssify/__init__.py | 1 - ssify/middleware.py | 10 ++++++++-- ssify/variables.py | 7 ++++--- ssify/version.py | 2 +- tox.ini | 6 ++++-- 9 files changed, 33 insertions(+), 13 deletions(-) create mode 100644 setup.cfg diff --git a/CHANGELOG.md b/CHANGELOG.md index d87720c..208ec31 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 0.2.4 (2015-04-16) + +* Django 1.8 compatibility. + +* Remove private headers from response. + +* Python-3 compatible get_version. + + ## 0.2.3 (2014-09-22) * Don't assume request object we are passed at any point still has diff --git a/README.md b/README.md index 042d91d..8a8aefd 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ License ![AGPL Logo](http://www.gnu.org/graphics/agplv3-155x51.png) - Copyright © 2014 Fundacja Nowoczesna Polska + Copyright © 2014,2015 Fundacja Nowoczesna Polska For full list of contributors see AUTHORS section at the end. diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..11d9c44 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,3 @@ +[bdist_wheel] +universal=1 + diff --git a/setup.py b/setup.py index 6228c5c..dc7946d 100755 --- a/setup.py +++ b/setup.py @@ -10,9 +10,9 @@ from setuptools import setup, find_packages def get_version(): basedir = os.path.dirname(__file__) with open(os.path.join(basedir, 'ssify/version.py')) as f: - VERSION = None - exec(f.read()) - return VERSION + variables = {} + exec(f.read(), variables) + return variables.get('VERSION') raise RuntimeError('No version info found.') diff --git a/ssify/__init__.py b/ssify/__init__.py index 74c1108..34c7040 100644 --- a/ssify/__init__.py +++ b/ssify/__init__.py @@ -17,7 +17,6 @@ from __future__ import unicode_literals from .version import VERSION __version__ = VERSION -__date__ = '2014-08-26' __all__ = ('flush_ssi_includes', 'ssi_expect', 'SsiVariable', 'ssi_included', 'ssi_variable') from .variables import ssi_expect, SsiVariable diff --git a/ssify/middleware.py b/ssify/middleware.py index fc57eb0..419a074 100644 --- a/ssify/middleware.py +++ b/ssify/middleware.py @@ -121,10 +121,14 @@ class SsiMiddleware(object): # Prepend the SSI variables. if hasattr(request, 'ssi_vars_needed'): vars_needed = request.ssi_vars_needed - else: - vars_needed = json_decode(response.get('X-Ssi-Vars-Needed', '{}')) + elif 'X-Ssi-Vars-Needed' in response: + vars_needed = json_decode(response['X-Ssi-Vars-Needed']) for k, v in vars_needed.items(): vars_needed[k] = SsiVariable(*v) + if not settings.DEBUG: + del response['X-Ssi-Vars-Needed'] + else: + vars_needed = None if vars_needed: response.content = provide_vars(request, vars_needed) + \ @@ -139,6 +143,8 @@ class SsiMiddleware(object): del response[header] else: response[header] = content + if not settings.DEBUG: + del response['X-ssi-restore'] else: for response_modifier in getattr(request, 'ssi_patch_response', []): response_modifier(response) diff --git a/ssify/variables.py b/ssify/variables.py index 46a787b..014e95f 100644 --- a/ssify/variables.py +++ b/ssify/variables.py @@ -11,7 +11,8 @@ at request time to the prerendered templates. """ from __future__ import unicode_literals from hashlib import md5 -from django import template +from django.template import Node +from django.template.base import get_library from django.utils.encoding import force_text, python_2_unicode_compatible from django.utils.functional import Promise from django.utils.safestring import mark_safe @@ -72,7 +73,7 @@ class SsiVariable(object): def get_value(self, request): """Computes the real value of the variable, using the request.""" taglib, tagname = self.tagpath.rsplit('.', 1) - return template.get_library(taglib).tags[tagname].get_value( + return get_library(taglib).tags[tagname].get_value( request, *self.args, **self.kwargs) def __str__(self): @@ -117,7 +118,7 @@ def ssi_expect(var, type_): return type_(var) -class SsiVariableNode(template.Node): +class SsiVariableNode(Node): """ Node for the SsiVariable tags. """ def __init__(self, tagpath, args, kwargs, patch_response=None, asvar=None): self.tagpath = tagpath diff --git a/ssify/version.py b/ssify/version.py index 6d09f02..911848b 100644 --- a/ssify/version.py +++ b/ssify/version.py @@ -1,3 +1,3 @@ from __future__ import unicode_literals -VERSION = '0.2.3' \ No newline at end of file +VERSION = '0.2.4' \ No newline at end of file diff --git a/tox.ini b/tox.ini index 0daa6e6..8aa3898 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,8 @@ [tox] envlist=clear, d1{5,6}-py{26,27,32,33}, - d{17,d}-py{27,32,33,34}, + d{17,18}-py{27,32,33,34}, + d{d}-py{27,33,34}, stats [testenv] @@ -14,7 +15,8 @@ deps= d15: Django>=1.5,<1.6 d16: Django>=1.6,<1.7 d17: Django>=1.7,<1.8 - dd: https://github.com/django/django/zipball/master + d18: Django>=1.8,<1.9 + dd: https://github.com/django/django/archive/master.tar.gz coverage basepython= py26: python2.6 -- 2.20.1