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?
+1
A:
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
Kousha
2010-02-21 03:09:59
Looks like a good solution but I haven't tested it yet. Nick Johnson recently made a post about this issue: http://blog.notdot.net/2010/03/Handling-downtime-The-capabilities-API-and-testingHe goes deeper into the Capabilities API uses that for the hooks.
markkoberlein
2010-03-03 17:46:59