fnp
/
fnpdjango.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
c10e014
)
add app settings
author
Radek Czajka
<radoslaw.czajka@nowoczesnapolska.org.pl>
Fri, 30 Nov 2012 11:44:55 +0000
(12:44 +0100)
committer
Radek Czajka
<radoslaw.czajka@nowoczesnapolska.org.pl>
Fri, 30 Nov 2012 11:44:55 +0000
(12:44 +0100)
fnpdjango/__init__.py
patch
|
blob
|
history
fnpdjango/deploy/templates/localsettings.py.template
patch
|
blob
|
history
fnpdjango/middleware.py
patch
|
blob
|
history
fnpdjango/utils/views.py
patch
|
blob
|
history
setup.py
patch
|
blob
|
history
diff --git
a/fnpdjango/__init__.py
b/fnpdjango/__init__.py
index
e69de29
..
17d547d
100644
(file)
--- a/
fnpdjango/__init__.py
+++ b/
fnpdjango/__init__.py
@@
-0,0
+1,8
@@
+from .utils.app import AppSettings
+
+class Settings(AppSettings):
+ REALIP = False
+ XACCEL = False
+
+
+app_settings = Settings('FNPDJANGO')
diff --git
a/fnpdjango/deploy/templates/localsettings.py.template
b/fnpdjango/deploy/templates/localsettings.py.template
index
551e00f
..
9e087fe
100644
(file)
--- a/
fnpdjango/deploy/templates/localsettings.py.template
+++ b/
fnpdjango/deploy/templates/localsettings.py.template
@@
-22,3
+22,6
@@
PIWIK_TOKEN = ''
MEDIA_ROOT = '%(app_path)s/media/'
STATIC_ROOT = '%(app_path)s/static/'
MEDIA_ROOT = '%(app_path)s/media/'
STATIC_ROOT = '%(app_path)s/static/'
+
+FNPDJANGO_REALIP = False
+FNPDJANGO_XACCEL = False
diff --git
a/fnpdjango/middleware.py
b/fnpdjango/middleware.py
index
21de872
..
fcf4c36
100644
(file)
--- a/
fnpdjango/middleware.py
+++ b/
fnpdjango/middleware.py
@@
-1,15
+1,18
@@
from django.utils import translation
from django.conf import settings
from django.http import Http404
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):
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):
class URLLocaleMiddleware(object):
diff --git
a/fnpdjango/utils/views.py
b/fnpdjango/utils/views.py
index
f2270cc
..
07f3905
100644
(file)
--- a/
fnpdjango/utils/views.py
+++ b/
fnpdjango/utils/views.py
@@
-2,13
+2,13
@@
View-specific utilities.
"""
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."""
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
response = HttpResponse()
response['Content-Type'] = ""
response['X-Accel-Redirect'] = url
diff --git
a/setup.py
b/setup.py
index
8e4f3bc
..
3dfd2e1
100755
(executable)
--- a/
setup.py
+++ b/
setup.py
@@
-22,7
+22,7
@@
def whole_trees(package_dir, paths):
setup(
name='fnpdjango',
setup(
name='fnpdjango',
- version='0.1.
1
',
+ version='0.1.
2
',
author='Radek Czajka',
author_email='radoslaw.czajka@nowoczesnapolska.org.pl',
url = '',
author='Radek Czajka',
author_email='radoslaw.czajka@nowoczesnapolska.org.pl',
url = '',