Created
November 13, 2012 16:35
-
-
Save pbdeuchler/4066816 to your computer and use it in GitHub Desktop.
Read Only Site Flag for Django (Request Processor)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def read_only_processor(request): | |
if read_only_flag(): | |
if request.method in ['GET', 'HEAD']: | |
return { | |
'read_only': True, | |
'error_message': 'Sorry, this site is read only right now!" | |
} | |
else: | |
#return a "Read only" response | |
else: | |
return {'read_only': False, 'error_message': ''} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Function returns a dictionary to be passed to the template processor