Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App Engine SDK DevServer Read-Only Mode?

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

like image 452
Mark Koberlein Avatar asked Feb 17 '10 19:02

Mark Koberlein


Video Answer


1 Answers

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

like image 68
Kousha Avatar answered Nov 08 '22 08:11

Kousha