Here is a small snippet of code that I use on applications deployed on Google AppEngine to inform users that the application is in maintenance mode. It usually happen when the AppEngine team put the datastore in read-only mode for maintenance purpose but other capabilities can be tested as well.
|
def requires_datastore_write(view): def newview(request, *args, **kwargs): from google.appengine.api import capabilities datastore_write_enabled = capabilities.CapabilitySet('datastore_v3', capabilities=['write']).is_enabled() if datastore_write_enabled: return view(request, *args, **kwargs) else: from django.shortcuts import render_to_response from django.template import RequestContext return render_to_response('maintenance.html', context_instance=RequestContext(request)) return newview |
This is a python […]