2016-06-02 6 views
9

からのアクセスデータストアエンティティ: https://cloud.google.com/appengine/docs/python/ndb/modelclass#class_methodsGAEデータストアNDB新機能:GAEデータストアNDBの新しいドキュメントを読んで、他のGAEアプリ

get_by_id(id, parent=None, app=None, namespace=None, **ctx_options) 

Returns an entity by ID. This is really just a shorthand for Key(cls, id).get() .

Arguments

id A string or integer key ID. parent Parent key of the model to get.

app (keyword arg) ID of app. If not specified, gets data for current app.

namespace (keyword arg) Namespace. If not specified, gets data for default namespace.

**ctx_options Context options Returns a model instance or None if not found.

は、私はこの新しいappパラメータを発見します。これは私が長い時間前から必要だったものです!!!!! 私はちょうど「xxxxxglobal」アプリからアプリ「xxxxxdev」のデータストアにアクセスしようとしましたが、私はこのエラーを取得:

File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/datastore/datastore_rpc.py", line 1373, in check_rpc_success 
    raise _ToDatastoreError(err) 
BadRequestError: app s~xxxxxglobal cannot access app xxxxxxdev's data 

私はアカウントサービスを追加[email protected][email protected]https://console.cloud.google.com/iam-admin/iam/

しかし、私はまだこの問題を受け取ります。

誰でも手伝ってもらえますか?コントロールパネルのどこにApp Engineの他のアプリへのデータストアアクセスを許可できるかを知る必要があります。

+0

the following comments in the sourceから、すでに働いオンされていますものです表示されますが、特にNDBのための機能のリクエストを投稿してお気軽に。 Googleのサービスアカウントの内容は非常に混乱しており、私は良い文書を見つけられませんでした。 –

+0

次の機能に関連する可能性があります:https://code.google.com/p/googleappengine/issues/detail?id=1300 –

+0

この回答に示唆されているように*何か*が既に動作している可能性があります:http://stackoverflow.com/a/25747058/4495081 –

答えて

1

現在、ndbはCloud Datastore APIを使用しておらず、通常の操作モードでは別のアプリのDatastoreに接続できません。コードが実行されているアプリのDatastoreにネイティブで接続します。

しかし、remote apiを使用すると、ndbを開発環境のさまざまなアプリケーションのデータストアに接続させることができます。

[Public Issue Tracker for App Engineには、1つのアプリから複数のデータストアにアクセスするための公開機能リクエストがあります。私はこの答えを見てみたい

current_app_id = os.environ.get('APPLICATION_ID', None) 
    if current_app_id and current_app_id != app_id: 
    # TODO(pcostello): We should support this so users can connect to different 
    # applications. 
    raise ValueError('Cannot create a Cloud Datastore context that connects ' 
        'to an application (%s) that differs from the application ' 
        'already connected to (%s).' % (app_id, current_app_id)) 
    os.environ['APPLICATION_ID'] = app_id 
関連する問題