Return 404 for unsupported languages in ssi_included views, 0.2.2
authorRadek Czajka <radekczajka@nowoczesnapolska.org.pl>
Fri, 19 Sep 2014 20:48:26 +0000 (22:48 +0200)
committerRadek Czajka <radekczajka@nowoczesnapolska.org.pl>
Fri, 19 Sep 2014 20:54:12 +0000 (22:54 +0200)
set zip_sae=False in setup.py, so that egg template loader is not required.

CHANGELOG.md
setup.py
ssify/decorators.py
ssify/models.py [new file with mode: 0644]
tox.ini

index 0dc426f..d112717 100644 (file)
@@ -1,5 +1,12 @@
 # Changelog
 
 # 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.
 ## 0.2.1 (2014-09-15)
 
 * Fix packaging errors.
index f475ee8..44705a2 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -7,7 +7,7 @@ from setuptools import setup, find_packages
 
 setup(
     name='django-ssify',
 
 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',
     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",
         "Programming Language :: Python :: 3.4",
         "Topic :: Internet :: WWW/HTTP",
         "Topic :: Software Development :: Code Generators",
-    ]
+    ],
+    zip_safe=False,
 )
 )
index 9caddd0..b513dbe 100644 (file)
@@ -9,6 +9,8 @@ from __future__ import unicode_literals
 import functools
 from inspect import getargspec
 import warnings
 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
 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)
                     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
                 current_lang = get_language()
                 activate(lang)
                 request.LANGUAGE_CODE = lang
diff --git a/ssify/models.py b/ssify/models.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tox.ini b/tox.ini
index 421e095..0daa6e6 100644 (file)
--- a/tox.ini
+++ b/tox.ini
 #
 [tox]
 envlist=clear,
 #
 [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]
     stats
 
 [testenv]
-indexserver=http://py.mdrn.pl
+indexserver=https://py.mdrn.pl:8443
 commands=coverage run --source=ssify --append --branch runtests.py
 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]
 
 [testenv:clear]
+basepython=python3.4
 commands=coverage erase
 
 [testenv:stats]
 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
 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}