[英]Replacing google.appengine.api import modules when upgrading to GAE3
We're moving from GAE 2 (standard) to 3. On GAE2 we used:我们正在从 GAE 2(标准)迁移到 3。在 GAE2 上,我们使用了:
from google.appengine.api import modules
CountryClient.COUNTRY_REALTIME_HOST = modules.get_hostname('api-country')
How can I do it on GAE3, considering that google.appengine.api
not is available?考虑到
google.appengine.api
不可用,我该如何在 GAE3 上做到这一点?
There is no direct equivalent to the google.appengine.api.modules
libraries in the Python 3 runtime for App Engine Standard. App Engine Standard 的 Python 3 运行时中没有与
google.appengine.api.modules
库直接等效的库。
However, as a workaround, you can use a combination of the App Engine Admin API and the default runtime environment variables .但是,作为一种解决方法,您可以结合使用 App Engine Admin API和默认运行时环境变量。
The Modules API is not supported on Python 3. You can use a combination of environment variables and the App Engine Admin API to obtain information about and modify your application's running services:
Python 3 不支持 Modules API。您可以结合使用环境变量和 App Engine Admin API 来获取有关应用程序正在运行的服务的信息并对其进行修改:
As you are calling the modules.get_hostname
with a module name (or service name, as now modules are usually referred as services), you could use the apps.services.get API call to retrieve which is the version handling all of the traffic, and then the apps.services.versions.instances.list API call to retrieve which is the instance name handling all of the traffic.当您使用模块名称(或服务名称,因为现在模块通常称为服务)调用
modules.get_hostname
时,您可以使用apps.services.get API 调用来检索处理所有流量的版本,然后调用apps.services.versions.instances.list API 来检索哪个是处理所有流量的实例名称。 Then you could build the Hosname as such:然后你可以像这样构建Hosname:
<Instance-ID>.<version.ID>.<service-ID>.<App-ID>.appspot.com
(Or if you are using a custom domain, you can replace the appspot.com
domain with it.) (或者,如果您使用的是自定义域,则可以用它替换
appspot.com
域。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.