From a7e203754929b2a49b33197811252ba88b3e047e Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Fri, 19 Sep 2014 22:48:26 +0200 Subject: [PATCH] Return 404 for unsupported languages in ssi_included views, set zip_sae=False in setup.py, so that egg template loader is not required. --- CHANGELOG.md | 7 +++ setup.py | 5 +- ssify/decorators.py | 4 ++ ssify/models.py | 0 tox.ini | 120 +++++++------------------------------------- 5 files changed, 31 insertions(+), 105 deletions(-) create mode 100644 ssify/models.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 0dc426f..d112717 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## 0.2.2 (2014-09-19) + +* Return 404 from ssi_included views with unsupported languages. + +* Set zip_safe=False, so egg loader middleware isn't required. + + ## 0.2.1 (2014-09-15) * Fix packaging errors. diff --git a/setup.py b/setup.py index f475ee8..44705a2 100755 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ from setuptools import setup, find_packages setup( name='django-ssify', - version='0.2.1', + version='0.2.2', author='Radek Czajka', author_email='radekczajka@nowoczesnapolska.org.pl', url='http://git.mdrn.pl/django-ssify.git', @@ -37,5 +37,6 @@ setup( "Programming Language :: Python :: 3.4", "Topic :: Internet :: WWW/HTTP", "Topic :: Software Development :: Code Generators", - ] + ], + zip_safe=False, ) diff --git a/ssify/decorators.py b/ssify/decorators.py index 9caddd0..b513dbe 100644 --- a/ssify/decorators.py +++ b/ssify/decorators.py @@ -9,6 +9,8 @@ from __future__ import unicode_literals import functools from inspect import getargspec import warnings +from django.conf import settings +from django.http import Http404 from django.template.base import parse_bits from django.utils.translation import get_language, activate from .cache import cache_include, DEFAULT_TIMEOUT @@ -39,6 +41,8 @@ def ssi_included(view=None, use_lang=True, lang = kwargs.pop('lang') except KeyError: raise exceptions.NoLangFieldError(request) + if lang not in [language[0] for language in settings.LANGUAGES]: + raise Http404 current_lang = get_language() activate(lang) request.LANGUAGE_CODE = lang diff --git a/ssify/models.py b/ssify/models.py new file mode 100644 index 0000000..e69de29 diff --git a/tox.ini b/tox.ini index 421e095..0daa6e6 100644 --- a/tox.ini +++ b/tox.ini @@ -3,117 +3,31 @@ # [tox] envlist=clear, - d15-py26, d15-py27, d15-py32, d15-py33, - d16-py26, d16-py27, d16-py32, d16-py33, - d17-py27, d17-py32, d17-py33, d17-py34, - dd-py27, dd-py32, dd-py33, dd-py34, + d1{5,6}-py{26,27,32,33}, + d{17,d}-py{27,32,33,34}, stats [testenv] -indexserver=http://py.mdrn.pl +indexserver=https://py.mdrn.pl:8443 commands=coverage run --source=ssify --append --branch runtests.py -deps=coverage +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 + coverage +basepython= + py26: python2.6 + py27: python2.7 + py32: python3.2 + py33: python3.3 + py34: python3.4 [testenv:clear] +basepython=python3.4 commands=coverage erase [testenv:stats] -commands=coverage html - -[base] - -[testenv:d15-py26] -basepython=python2.6 -deps= - Django>=1.5,<1.6 - {[testenv]deps} - -[testenv:d15-py27] -basepython=python2.7 -deps= - Django>=1.5,<1.6 - {[testenv]deps} - -[testenv:d15-py32] -basepython=python3.2 -deps= - Django>=1.5,<1.6 - {[testenv]deps} - -[testenv:d15-py33] -basepython=python3.3 -deps= - Django>=1.5,<1.6 - {[testenv]deps} - -[testenv:d16-py26] -basepython=python2.6 -deps= - Django>=1.6,<1.7 - {[testenv]deps} - -[testenv:d16-py27] -basepython=python2.7 -deps= - Django>=1.6,<1.7 - {[testenv]deps} - -[testenv:d16-py32] -basepython=python3.2 -deps= - Django>=1.6,<1.7 - {[testenv]deps} - -[testenv:d16-py33] -basepython=python3.3 -deps= - Django>=1.6,<1.7 - {[testenv]deps} - -[testenv:d17-py27] -basepython=python2.7 -deps= - https://www.djangoproject.com/download/1.7c3/tarball/ - {[testenv]deps} - -[testenv:d17-py32] -basepython=python3.2 -deps= - Django>=1.7,<1.8 - {[testenv]deps} - -[testenv:d17-py33] -basepython=python3.3 -deps= - Django>=1.7,<1.8 - {[testenv]deps} - -[testenv:d17-py34] basepython=python3.4 -deps= - Django>=1.7,<1.8 - {[testenv]deps} - -[testenv:dd-py27] -basepython=python2.7 -deps= - https://github.com/django/django/zipball/master - {[testenv]deps} - -[testenv:dd-py32] -basepython=python3.2 -deps= - https://github.com/django/django/zipball/master - {[testenv]deps} - -[testenv:dd-py33] -basepython=python3.3 -deps= - https://github.com/django/django/zipball/master - {[testenv]deps} +commands=coverage html -[testenv:dd-py34] -basepython=python3.4 -deps= - https://github.com/django/django/zipball/master - {[testenv]deps} -- 2.20.1