- June 30, 2010
- Not specified
- maintenance appengine readonly capabilities datastore decorator
- 0 (after 0 ratings)
This code defines a decorator that inform users of your site when the Google AppEngine data store is in read-only mode during maintenance periods.
Use it as a decorator on your views that require write access to the data store.
@requires_datastore_write def update(request): ...
maintenance.html Django template (or change the name in the code) with the message that the user will see, something like:
This application is currently in maintenance mode and some operations are temporarily unavailable. Thanks for trying back later. Sorry for the inconvenience.
1 2 3 4 5 6 7 8 9 10 11 12 13
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