App Engine SDK DevServer只读模式?

时间:2010-02-17 19:37:01

标签: google-app-engine

有没有办法以只读模式运行app engine dev服务器,以便模拟Google的计划维护,这会将数据存储置于只读模式?

Gracefully Degrading During Scheduled Maintenance

1 个答案:

答案 0 :(得分:2)

我希望有一个复选框可以使数据存储区为只读。这个黑客似乎做了我需要的。将以下内容放在主处理程序中:

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()

在这里找到: http://groups.google.com/group/google-appengine/msg/51db9d51401715ca