App Engine SDK DevServer只读模式? [英] App Engine SDK DevServer Read-Only Mode?
本文介绍了App Engine SDK DevServer只读模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法以只读模式运行应用程序引擎开发服务器,以便模拟Google的计划维护,将数据存储设置为只读模式?
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?
推荐答案
我希望有一个复选框可以使数据存储为只读。这种黑客似乎正在做我所需要的。将以下代码放入您的主要处理程序中:
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()
这里发现:
http://groups.google.com/group/google-appengine/msg/51db9d51401715ca
这篇关于App Engine SDK DevServer只读模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文