Google App Engine数据存储区写道:​​如何远程启用/禁用只读模式? [英] Google App Engine Datastore Writes: How to enable/disable read-only mode remotely?

查看:110
本文介绍了Google App Engine数据存储区写道:​​如何远程启用/禁用只读模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在阅读备份 GAE的数据存储区时,

我们强烈建议您在备份或还原过程中将应用程序设置为只读模式.

We strongly recommend that you set your application to read-only mode during a backup or restore...

粗略检查后,似乎 做到这一点的唯一方法是通过GAE网络管理员界面,您可以在其中禁用重新启用在页面某处写.

After a cursory inspection, it appears that the only way to do this is via the GAE web admin UI, where you either Disable or Re-Enable Writes inside a page somewhere.

我想编写一些Ant构建文件和/或shell和/或Python脚本,使我可以自动备份/还原GAE应用程序的数据存储区.这意味着我将需要一种方法来自动启用/禁用对写入(从只读"模式进入和退出我的应用程序)到我的数据存储区的写入,所有这些操作都来自某个脚本(例如我说过的Ant,bash)或Python).

I would like to write some Ant buildfiles and/or shell and/or Python scripts that would allow me to backup/restore my GAE app's Datastore automatically. This would mean I would need a way to automate the enabling/disabling of writes (putting my app into and out from a "read-only" mode) to my Datastore, all from inside some script (like I said, either Ant, bash or Python).

所以我问:这有可能吗?还是必须"(通过Web管理员UI)手动"完成的某些操作?预先感谢!

So I ask: is this even possible? Or is this something that must be done "manually" (via the web admin UI)? Thanks in advance!

推荐答案

功能您可以使用Python API 来读取应用程序某些功能的状态,例如DataStore写入.不幸的是,此Api仅具有读取状态的方法,而没有用于设置状态的方法.

The Capabilities Python API is the one that you can use yo read the state of some capabilities of your app like DataStore writes. Unfortunately this Api only have methods to read the state, but not for set the state.

由于代码必须查阅Capabilities API才能获取App引擎中每个功能的状态,并避免因过度配额,系统维护等而导致失败.一种可能的解决方案是将一种接口放在前面标志中的功能API的禁用",以禁用每个功能.

Since the code must consult the Capabilities API to get the state of each functionality in the App-engine, and avoid failures by over-quota, system maintenance etc... One possible solution is to put a kind of interface in front of the Capabilities API within flags to disable each functionality.

伪代码,即:

class DatasToreWriteCapabiliti{
  boolean DATASTORE_WRITE = true;

  public disable(){ DATASTORE_WRITE = false;}
  public enable(){ DATASTORE_WRITE = true;}

  public CapabilityStatus status(){
     if(DATASTORE_WRITE == false) return CapabilityStatus.DISABLED;

     CapabilitiesService service = CapabilitiesServiceFactory.getCapabilitiesService();
     return service.getStatus(Capability.DATASTORE_WRITE).getStatus();
  }
}

这篇关于Google App Engine数据存储区写道:​​如何远程启用/禁用只读模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆