from django.conf import settings
# Change this to reflect your settings.py file
from site_settings import settings as local_settings
class iPhoneMiddleware(object):
"""
iPhone Middleware. Dynamically adds the iPhone template dirs if
iPhone user agent is present
"""
def __init__(self):
self.iphone_templates = ('/home/video/sources/video/templates/iphone_templates',)
def process_request(self, request):
if request.META['HTTP_USER_AGENT'].find('iPhone') != -1:
settings.TEMPLATE_DIRS = self.iphone_templates + local_settings.TEMPLATE_DIRS
else:
settings.TEMPLATE_DIRS = local_settings.TEMPLATE_DIRS
return
Comments