+from .utils.app import AppSettings
+
+class Settings(AppSettings):
+ REALIP = False
+ XACCEL = False
+
+
+app_settings = Settings('FNPDJANGO')
MEDIA_ROOT = '%(app_path)s/media/'
STATIC_ROOT = '%(app_path)s/static/'
+
+FNPDJANGO_REALIP = False
+FNPDJANGO_XACCEL = False
from django.utils import translation
from django.conf import settings
from django.http import Http404
+from . import app_settings
class SetRemoteAddrFromXRealIP(object):
"""Sets REMOTE_ADDR from the X-Real-IP header, as set by Nginx."""
def process_request(self, request):
- try:
- request.META['REMOTE_ADDR'] = request.META['HTTP_X_REAL_IP']
- except KeyError:
- return None
+ if app_settings.REALIP:
+ try:
+ request.META['REMOTE_ADDR'] = request.META['HTTP_X_REAL_IP']
+ except KeyError:
+ pass
+ return None
class URLLocaleMiddleware(object):
View-specific utilities.
"""
-from django.conf import settings
+from .. import app_settings
from django.http import HttpResponse, HttpResponseRedirect
def serve_file(url):
"""Serves an URL either though Nginx's X-accel, or by redirection."""
- if settings.X_ACCEL_REDIRECT:
+ if app_settings.XACCEL:
response = HttpResponse()
response['Content-Type'] = ""
response['X-Accel-Redirect'] = url
setup(
name='fnpdjango',
- version='0.1.1',
+ version='0.1.2',
author='Radek Czajka',
author_email='radoslaw.czajka@nowoczesnapolska.org.pl',
url = '',