Just for the record:

** settings.py in $project_path:

# Maintenance Mode Switch
MAINTENANCE = True

# Login paths
LOGIN_REDIRECT_URL = '/admin/'
LOGIN_URL = '/admin/'
LOGOUT_URL = '/admin/logout/'

# This will be shown to unauthorised users when the site is in maintenance 
mode
MAINTENANCE_PATH = '/maintenance/'

** middleware.py in $project_path:

class MaintenanceMiddleware(object):
    def process_request(self, request):
        from django.conf import settings
        from django.http import HttpResponseRedirect


        is_login = request.path in (
            settings.LOGIN_REDIRECT_URL,
            settings.LOGIN_URL,
            settings.LOGOUT_URL,
            settings.MAINTENANCE_PATH,
        )
        if ((not is_login) and settings.MAINTENANCE and (not 
request.user.is_authenticated())):
            return HttpResponseRedirect(settings.MAINTENANCE_PATH)
        return None

I have added the MAINTENANCE_PATH setting, and included it in the path check. 
If this one is not checked to be false, we get an endless redirect loop.

I'll be posting this into my new blog (as soon as I get it up) and if you like 
it and find it usefull, you might also tell me to post it at Django Snippets.

Thank you everyone!

Chris Hoeppner
www.pixware.org

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to