【问题标题】:Sharing Entity Keys Between Applications在应用程序之间共享实体密钥
【发布时间】:2013-06-25 01:48:43
【问题描述】:

我想知道是否可以/允许在两个应用程序之间共享一个实体,例如一个应用程序创建并存储实体,然后第二个应用程序从第一个应用程序获取密钥,然后可以访问该实体? Second.py 是否需要在其中包含 Ent 类信息,还是仅通过对象就可以了解有关 Ent 的所有信息?

First.py:

class Ent(db.model):
    def stuff():
        print "I belong to first"
class out(webapp2.RequestHandler):
    def get():
        e = Ent()
        key = e.put()
        return key

Second.py:

class in(webapp2.RequestHandler): 
    response = urllib2.urlopen(urlOfFirstApp)
    ent = #access BigTable with response/key, I'm not sure how to do this or if I can or if I'm allowed to
    ent.stuff()

【问题讨论】:

  • first.py 中有一个错误。 e.put 后面的括号你忘了;)
  • 感谢修复。老实说,这应该是有点失控的伪代码。

标签: python google-app-engine google-cloud-datastore urllib2 webapp2


【解决方案1】:

这取决于您的数据存储在哪里。如果它存储在 GAE 数据存储中,它只能存储在一个应用程序的数据存储中,并且必须通过某种 HTTP API 由另一个应用程序访问。但是,如果它存储在 Google Cloud Storage 之类的东西中,您可以(我认为)共享标识符并从多个应用程序访问。

【讨论】:

  • 我从来没有意识到有什么不同,我认为 GAE 数据存储是 BigTable 并且只是被所有东西共享。
  • @EasilyBaffled:想想那将是多么的灾难。任何人都可以暴力破解密钥或 ID 并访问其他人的数据。另请参阅this 问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-07-26
  • 2021-06-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-06-08
相关资源
最近更新 更多