Wow, was that ever easy. Thanks for your help!
Kurt
For future googlers:
settings.py:
MIDDLEWARE_CLASSES = (
...
'redirector.ConstructionFilterMiddleware',
...
)
redirector/__init__.py:
from django.shortcuts import render_to_response
from django.conf import settings
class ConstructionFilterMiddleware(object):
"""
This middleware redirects all requests from clients that are
not in INTERNAL_IPS to the construction.html page
"""
def process_request(self, request):
remote_addr = request.META['REMOTE_ADDR']
is_internal = remote_addr in settings.INTERNAL_IPS
if not is_internal:
return render_to_response( 'construction.html' )