Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.tox/
*.pyc
*.egg-info/
7 changes: 6 additions & 1 deletion django_mobile/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from django.conf import settings as django_settings
import django

CACHE_LOADER_NAME = 'django_mobile.loader.CachedLoader'
DJANGO_MOBILE_LOADER = 'django_mobile.loader.Loader'
Expand Down Expand Up @@ -30,7 +31,11 @@ class defaults(object):
FLAVOURS_COOKIE_HTTPONLY = False
FLAVOURS_SESSION_KEY = u'flavour'
FLAVOURS_TEMPLATE_LOADERS = []
for loader in django_settings.TEMPLATE_LOADERS:
if django.VERSION[0] < 2 and django.VERSION[1] < 8 :
TEMPLATES = django_settings.TEMPLATE_LOADERS
else:
TEMPLATES = django_settings.TEMPLATES[0]['OPTIONS']['loaders']
for loader in TEMPLATES:
if isinstance(loader, (tuple, list)) and loader[0] == CACHE_LOADER_NAME:
for cached_loader in loader[1]:
if cached_loader != DJANGO_MOBILE_LOADER:
Expand Down
23 changes: 16 additions & 7 deletions django_mobile_tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,22 @@
ROOT_URLCONF = 'django_mobile_tests.urls'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
('django_mobile.loader.CachedLoader', (
'django_mobile.loader.Loader',
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)),
)
TEMPLATES= [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'OPTIONS':{
'loaders':(
('django_mobile.loader.CachedLoader', (
'django_mobile.loader.Loader',
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)),
)
}
}
]

TEMPLATE_LOADERS = TEMPLATES[0]['OPTIONS']['loaders']

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
Expand Down
2 changes: 1 addition & 1 deletion django_mobile_tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def test_functional(self):
result = result.strip()
self.assertEqual(result, 'Hello .')
# simulate RequestContext
result = render_to_string('index.html', context_instance=RequestContext(Mock()))
result = render_to_string('index.html', context = RequestContext(Mock()).flatten())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space before and after the =
context=RequestContext(Mock())

result = result.strip()
self.assertEqual(result, 'Hello full.')
set_flavour('mobile')
Expand Down
9 changes: 4 additions & 5 deletions django_mobile_tests/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@


def index(request):
return render_to_response('index.html', {
}, context_instance=RequestContext(request))
return render_to_response('index.html',
context=RequestContext(request).flatten())


urlpatterns = patterns('',
urlpatterns = [
url(r'^$', index),
url(r'^cached/$', cache_page(60*10)(index)),
)
]
8 changes: 5 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
minversion = 1.8
envlist =
py26-{15,16},
py27-{15,16,17,18,19,master},
py27-{15,16,17,18,19,110,master},
py33-{17,18,master},
py34-{17,18,19,master},
pypy-{15,16,17,18,19,master}
py34-{17,18,19,110,master},
pypy-{15,16,17,18,19,110,master}

[testenv]
commands = python runtests.py
deps =
pdbpp
15: Django >= 1.5, < 1.6
16: Django >= 1.6, < 1.7
17: Django >= 1.7, < 1.8
18: Django >= 1.8, < 1.9
19: Django >= 1.9, < 1.10
110: Django >= 1.10, <1.11
master: https://github.com/django/django/tarball/master#egg=Django
-r{toxinidir}/requirements/tests.txt