Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Адаптация к новой джанге #84

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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: 1 addition & 1 deletion django_mobile/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

__author__ = u'Gregor Müllegger'
__version__ = '0.7.0.dev1'
__version__ = '0.7.0.dev2'


import threading
Expand Down
4 changes: 2 additions & 2 deletions django_mobile/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ class Loader(BaseLoader):
def get_contents(self, origin):
return origin.loader.get_contents(origin)

def get_template_sources(self, template_name, template_dirs=None):
def get_template_sources(self, template_name):
template_name = self.prepare_template_name(template_name)
for loader in self.template_source_loaders:
if hasattr(loader, 'get_template_sources'):
try:
for result in loader.get_template_sources(template_name, template_dirs):
for result in loader.get_template_sources(template_name):
yield result
except UnicodeDecodeError:
# The template dir name was a bytestring that wasn't valid UTF-8.
Expand Down
8 changes: 5 additions & 3 deletions django_mobile/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
from django_mobile import flavour_storage
from django_mobile import set_flavour, _init_flavour
from django_mobile.conf import settings
from django.utils.deprecation import MiddlewareMixin


class SetFlavourMiddleware(object):
class SetFlavourMiddleware(MiddlewareMixin):
def process_request(self, request):
_init_flavour(request)

Expand All @@ -18,7 +19,7 @@ def process_response(self, request, response):
return response


class MobileDetectionMiddleware(object):
class MobileDetectionMiddleware(MiddlewareMixin):
user_agents_test_match = (
"w3c ", "acs-", "alav", "alca", "amoi", "audi",
"avan", "benq", "bird", "blac", "blaz", "brew",
Expand All @@ -44,7 +45,8 @@ class MobileDetectionMiddleware(object):
))
http_accept_regex = re.compile("application/vnd\.wap\.xhtml\+xml", re.IGNORECASE)

def __init__(self):
def __init__(self, get_response=None):
super().__init__(get_response=get_response)
user_agents_test_match = r'^(?:%s)' % '|'.join(self.user_agents_test_match)
self.user_agents_test_match_regex = re.compile(user_agents_test_match, re.IGNORECASE)
self.user_agents_test_search_regex = re.compile(self.user_agents_test_search, re.IGNORECASE)
Expand Down