简体   繁体   English

我可以访问其他Google App Engine应用程序的数据存储区实体吗?

[英]Can I access Datastore entities of my other Google App Engine Applications

As we know, in Google App engine, for each registered email account, we are allowed to make 10 applications. 众所周知,在Google App引擎中,对于每个注册的电子邮件帐户,我们可以制作10个应用程序。 Now, I need to share entities among the applications. 现在,我需要在应用程序之间共享实体。 Is this possible? 这可能吗? If yes, how is it implemented? 如果是,它是如何实施的?

No, this cannot be done. 不,这不可能。 However, as Nick Johnson points out, you can use remote_api to do what you need. 但是,正如尼克约翰逊指出的那样,你可以使用remote_api来做你需要的事情。

Are you sure you really need to do this? 你确定你真的需要这样做吗? Don't forget, you can have multiple versions of an application running against the same datastore. 不要忘记,您可以在同一数据存储区上运行多个版本的应用程序。 Only 1 version of the app is your "default" and gets your non appspot.com domain name, but you can have completely different codebases running against the same datastore/memcache addressable with ..appspot.com 只有1个版本的应用程序是您的“默认”并获取您的非appspot.com域名,但您可以使用..appspot.com针对相同的数据存储区/内存缓存运行完全不同的代码库

I don't know if this satisfies your needs but thought I'd throw it out there. 我不知道这是否满足你的需求,但我想我会把它扔出去。

Yo can do it using Cloud Datastore API access. Yo可以使用Cloud Datastore API访问来实现。 Until now, I can't be able to do it using ndb library. 到现在为止,我无法使用ndb库来完成它。

This is the code (Python) in your current app: 这是您当前应用中的代码(Python):

from google.appengine.api import app_identity

scope = "https://www.googleapis.com/auth/datastore"
authorization_token, _ = app_identity.get_access_token(scope)
headers = {'Content-Type': 'application/json', "Authorization": "Bearer " + authorization_token}
payload = {"gqlQuery": { "queryString": "SELECT * FROM Entities"} }
url = "https://datastore.googleapis.com/v1beta3/projects/otherAppName:runQuery"

result = urlfetch.fetch(url, payload=json.dumps(payload), method=urlfetch.POST,
     follow_redirects=True, headers=headers)

just change "otherAppName" with the short name of the other App Engine app whose datastore you want to access. 只需使用您要访问其数据存储的其他App Engine应用程序的短名称更改“otherAppName”。 Change "Entities" with the name of the Model you want to access. 使用您要访问的模型的名称更改“实体”。 Remember to give access to yourCurrentApp in the otherNameApp (IAM menu in the cloud console), set permissions to yourcurrentapp@appspot.gserviceaccount.com to access the datastore/project 请记住在otherNameApp(云控制台中的IAM菜单)中授予对currentCurrentApp的访问权限,设置对yourcurrentapp@appspot.gserviceaccount.com的权限以访问数据存储区/项目

In result you will get the response, you must json-parse it and you will get a very low level detail of the datastore entities from the query (including keys, paths, field names, types and value for each field and each row of the results). 结果你将得到响应,你必须json解析它,你将从查询中获得数据存储区实体的非常低级别的细节(包括键,路径,字段名称,每个字段的类型和值以及每个字段的每一行结果)。 If you have ndb.JsonProperties you will receive a BLOB value (DATABLOB in the next example code) , you must transform it : 如果您有ndb.JsonProperties,您将收到一个BLOB值(在下一个示例代码中为DATABLOB),您必须对其进行转换:

from google.appengine.ext.bulkload import transform 
b = json.loads(transform.blobproperty_from_base64(DATOBLOB))

Hope this can help you. 希望这可以帮到你。 I'm waiting for the answer using ndb in my other post: GAE NDB Datastore new feature: Access Datastore entities from other GAE app 我在其他帖子中使用ndb等待答案: GAE NDB数据存储区新功能:从其他GAE应用程序访问数据存储区实体

有一种新的可能性:如果其中一个应用程序可以成为另一个应用程序的“一部分”,则可以将其作为“模块”。

通过在App Engine的设置中激活Cloud Datastore访问 ,可以与其他App Engine应用程序(或第三方应用程序)共享数据存储。

Check the ISSUE with GAE before going to implement as stated in documentation. 在按照文档中的说明进行实施之前,请使用GAE检查问题 I had tried to implement as stated there but with fail because of the issue. 我试图按照那里的规定实施但由于问题而失败了。 Your request to the remote API will reach the target server but won't perform anything. 您对远程API的请求将到达目标服务器,但不会执行任何操作。 Hope that the issue be solved soon. 希望问题尽快得到解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM