如何获得谷歌应用程序引擎上的名称空间列表? [英] How do I get a list of namespaces on google app engine?
本文介绍了如何获得谷歌应用程序引擎上的名称空间列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想对数据存储中的所有用户数据进行备份。我的应用程序使用新的名称空间功能来为每个用户提供多租户(根据文档中的示例)。
批量加载程序需要每个名称空间客户下载数据。我没有保存用户列表,所以我不能生成名称空间。有没有一种检测所有当前使用的命名空间的方法?
解决方案
from google.appengine.ext.db在metadata.get_namespaces()中为ns导入元数据
:
printnamespace:'%s'%ns.namespace_name
对于NDB,导入略有不同:
from google.appengine.ext.ndb import metadata
I would like to make a backup of all user data in the datastore. My application is using the new namespace feature to provide multi tenanting on a per user basis (as per the example in the docs).
The bulk loader needs the namespace for each customer to download the data. I don't keep a list of users, so I can't generate the namespaces. Is there a method of detecting all the currently used namespaces?
解决方案
Since SDK 1.4.0 you can use Metadata Queries:
from google.appengine.ext.db import metadata
for ns in metadata.get_namespaces():
print "namespace: '%s'" % ns.namespace_name
For NDB the import is slightly different:
from google.appengine.ext.ndb import metadata
这篇关于如何获得谷歌应用程序引擎上的名称空间列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文