Merge pull request #72 from jsocol/dj18

django 1.8 compatability fixes
This commit is contained in:
James Socol 2015-05-13 10:05:41 -04:00
commit 357f17a9f8
4 changed files with 37 additions and 6 deletions

View File

@ -9,9 +9,11 @@ env:
- TOX_ENV=py27-1.5 - TOX_ENV=py27-1.5
- TOX_ENV=py27-1.6 - TOX_ENV=py27-1.6
- TOX_ENV=py27-1.7 - TOX_ENV=py27-1.7
- TOX_ENV=py27-1.8
- TOX_ENV=py33-1.5 - TOX_ENV=py33-1.5
- TOX_ENV=py33-1.6 - TOX_ENV=py33-1.6
- TOX_ENV=py33-1.7 - TOX_ENV=py33-1.7
- TOX_ENV=py33-1.8
install: install:
- pip install tox - pip install tox
script: script:

View File

@ -9,12 +9,23 @@ import re
from django.conf import settings from django.conf import settings
from django.template.base import Origin, TemplateDoesNotExist from django.template.base import Origin, TemplateDoesNotExist
from django.template.context import get_standard_processors
from django.template.loader import BaseLoader from django.template.loader import BaseLoader
from django.utils.importlib import import_module from django.utils.importlib import import_module
import jinja2 import jinja2
try:
from django.template.engine import Engine
has_engine = True
def get_standard_processors():
return Engine.get_default().template_context_processors
except ImportError:
from django.template.context import get_standard_processors
has_engine = False
VERSION = (0, 7, 1) VERSION = (0, 7, 1)
__version__ = '.'.join(map(str, VERSION)) __version__ = '.'.join(map(str, VERSION))
@ -200,7 +211,10 @@ class Loader(BaseLoader):
env.template_class = Template env.template_class = Template
def __init__(self): def __init__(self):
super(Loader, self).__init__() if has_engine:
super(Loader, self).__init__(Engine.get_default())
else:
super(Loader, self).__init__()
include_pattern = getattr(settings, 'JINGO_INCLUDE_PATTERN', None) include_pattern = getattr(settings, 'JINGO_INCLUDE_PATTERN', None)
if include_pattern: if include_pattern:
self.include_re = re.compile(include_pattern) self.include_re = re.compile(include_pattern)

View File

@ -86,16 +86,19 @@ def patch():
# Replace StrAndUnicode with SafeStrAndUnicode in the inheritance # Replace StrAndUnicode with SafeStrAndUnicode in the inheritance
# for all these classes. # for all these classes.
classes = ( classes = [
forms.BaseForm, forms.BaseForm,
forms.BoundField, forms.BoundField,
formsets.BaseFormSet, formsets.BaseFormSet,
util.ErrorDict, util.ErrorDict,
util.ErrorList, util.ErrorList,
widgets.Media, widgets.Media,
widgets.RadioInput,
widgets.RadioFieldRenderer, widgets.RadioFieldRenderer,
) ]
try:
classes.append(widgets.RadioChoiceInput)
except AttributeError:
classes.append(widgets.RadioInput)
if has_str_and_unicode: if has_str_and_unicode:
for cls in classes: for cls in classes:

14
tox.ini
View File

@ -1,5 +1,5 @@
[tox] [tox]
envlist = py26-1.4, py26-1.5, py26-1.6, py27-1.4, py27-1.5, py27-1.6, py27-1.7, py33-1.5, py33-1.6, py33-1.7 envlist = py26-1.4, py26-1.5, py26-1.6, py27-1.4, py27-1.5, py27-1.6, py27-1.7, py27-1.8, py33-1.5, py33-1.6, py33-1.7, py33-1.8
toxworkdir = {homedir}/.tox-jingo toxworkdir = {homedir}/.tox-jingo
[testenv] [testenv]
@ -53,6 +53,12 @@ deps =
Django>=1.7,<1.8 Django>=1.7,<1.8
{[testenv]deps} {[testenv]deps}
[testenv:py27-1.8]
basepython = python2.7
deps =
Django>=1.8,<1.9
{[testenv]deps}
[testenv:py33-1.5] [testenv:py33-1.5]
basepython = python3.3 basepython = python3.3
deps = deps =
@ -70,3 +76,9 @@ basepython = python3.3
deps = deps =
Django>=1.7,<1.8 Django>=1.7,<1.8
{[testenv]deps} {[testenv]deps}
[testenv:py33-1.8]
basepython = python3.3
deps =
Django>=1.8,<1.9
{[testenv]deps}