Is there a way to run the app engine dev server in read-only mode in order to simulate the scheduled maintenance by Google which puts the datastore into read-only mode?
Gracefully Degrading During Scheduled Maintenance
I wish there was a checkbox that would make the datastore read-only. This hack seems to do what I need. Put the following in your main handler:
from google.appengine.runtime.apiproxy_errors import CapabilityDisabledError
from google.appengine.api import apiproxy_stub_map
def make_datastore_readonly():
"""Throw ReadOnlyError on put and delete operations."""
def hook(service, call, request, response):
assert(service == 'datastore_v3')
if call in ('Put', 'Delete'):
raise CapabilityDisabledError('Datastore is in read-only mode')
apiproxy_stub_map.apiproxy.GetPreCallHooks().Push('readonly_datastore', hook, 'datastore_v3')
def main():
make_datastore_readonly()
It was found here: http://groups.google.com/group/google-appengine/msg/51db9d51401715ca
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With