From: Radek Czajka Date: Thu, 16 Apr 2015 13:21:01 +0000 (+0200) Subject: Merge branch 'master' of ssh://git.mdrn.pl/django-ssify X-Git-Tag: 0.2.5~1 X-Git-Url: https://git.mdrn.pl/django-ssify.git/commitdiff_plain/325450f83527058794f7b9f5e76348afa9a06ec4?hp=e89d22d4e7a6d5846fe964851b0f1a209bf0a521 Merge branch 'master' of ssh://git.mdrn.pl/django-ssify Conflicts: tox.ini --- 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 5954c8d..063a6b3 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,8 @@ [tox] envlist=clear, d1{5,6}-py{26,27,32,33,py}, - d{17,d}-py{27,32,33,34,py}, + d{17,18}-py{27,32,33,34,py}, + d{d}-py{27,33,34,py}, 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 [testenv:clear]