- June 30, 2010
- Not specified
- 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
More like this
- Month / Year SelectDateWidget based on django SelectDateWidget by pierreben 3 weeks, 5 days ago
- Python Django CRUD Example Tutorial by tuts_station 1 month, 1 week ago
- Browser-native date input field by kytta 2 months, 3 weeks ago
- Generate and render HTML Table by LLyaudet 3 months ago
- My firs Snippets by GutemaG 3 months, 1 week ago