Python 2.7 已达到支持终止期限,并将于 2026 年 1 月 31 日
弃用。弃用后,您将无法部署 Python 2.7 应用,即使您的组织之前曾使用组织政策重新启用旧版运行时的部署也是如此。现有的 Python 2.7 应用在
弃用日期之后将继续运行并接收流量。我们建议您
迁移到最新支持的 Python 版本。
WSGI 服务库
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
此模块包含用于将 Google Protocol RPC 服务作为 WSGI 应用进行发布的类。
protorpc.wsgi.service 软件包提供以下函数:
- service_mapping(service_factory, service_path=r'.*', protocols=None)
-
创建可处理单项 Google Protocol RPC 服务映射的 WSGI 应用。
参数
- service_factory
- 用于创建服务的新实例的服务类或服务工厂。如需详细了解服务工厂,请参阅 remote.Service.new_factory。
- service_path=r'.*'
- 服务所在的路径。
- protocols=None
- 用于在服务器上配置支持的协议的 remote.Protocols 实例。
返回一个处理单项 Google Protocol RPC 服务映射的 WSGI 应用。
- service_mappings(services, registry_path=DEFAULT_REGISTRY_PATH)
-
创建具有多项服务映射的 WSGI 应用,可选择指定注册表服务(非必需)。例如:
from protorpc import remote
from protorpc.wsgi import service
package = 'my_package'
class MyService(remote.Service):
...
class MyOtherService(remote.Service):
...
app = service.service_mappings(
[('/my_path', MyService), # Maps to /my_path
('/my_other_path', MyOtherService), # Maps to /my_other_path
])
通过指定元组 (path, service) 将服务映射到网址路径,其中 path 是服务所在的路径,而 service 是用于创建服务的新实例的服务类或服务工厂。如需详细了解服务工厂,请参阅 remote.Service.new_factory。
参数
- 项服务
- 元组列表(路径,服务),其中
path 是服务所在的路径,service 是用于创建服务的新实例的服务类或服务工厂。如需详细了解服务工厂,请参阅 remote.Service.new_factory。
- registry_path=DEFAULT_REGISTRY_PATH
- 提供注册表服务的路径。使用 None 停用注册表服务。
返回具有多项服务映射的 WSGI 应用,可能附带非必需的注册表服务。
在提供重复路径时引发 ServiceConfigurationError。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-09-04。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-04。"],[[["\u003cp\u003eThis module provides tools to publish Google Protocol RPC services as WSGI applications.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eservice_mapping\u003c/code\u003e function creates a WSGI application for a single RPC service, using a service factory or class to instantiate the service.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eservice_mappings\u003c/code\u003e function enables the creation of a WSGI application that hosts multiple services, each mapped to a specific URL path.\u003c/p\u003e\n"],["\u003cp\u003eBoth functions allow the use of service factories for the creation of service instances.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eservice_mappings\u003c/code\u003e function can include an optional registry service and will raise a \u003ccode\u003eServiceConfigurationError\u003c/code\u003e if duplicate paths are given.\u003c/p\u003e\n"]]],[],null,["# WSGI Service Library\n\nThis module contains classes that publish a Google Protocol RPC service as a WSGI application.\n\nThe `protorpc.wsgi.service` package provides the following functions:\n\nservice_mapping(service_factory, service_path=r'.\\*', protocols=None)\n\n: Creates a WSGI application that handles a single Google Protocol RPC service mapping.\n\n **Arguments**\n\n service_factory\n : The service class or service factory for creating new instances of the service. For more information about service factories, please see [remote.Service.new_factory](/appengine/docs/legacy/standard/python/tools/protorpc/remote/serviceclass#new_factory).\n\n service_path=r'.\\*'\n : The path where the service resides.\n\n protocols=None\n : A remote.Protocols instance that configures supported protocols on the server.\n\n Returns a WSGI application that handles a single Google Protocol RPC service mapping.\n\nservice_mappings(services, registry_path=DEFAULT_REGISTRY_PATH)\n\n: Creates a WSGI application with multiple service mappings with an optional registry service. For example:\n\n ```python\n from protorpc import remote\n from protorpc.wsgi import service\n\n package = 'my_package'\n\n class MyService(remote.Service):\n ...\n\n class MyOtherService(remote.Service):\n ...\n\n app = service.service_mappings(\n [('/my_path', MyService), # Maps to /my_path\n ('/my_other_path', MyOtherService), # Maps to /my_other_path\n ])\n ```\n\n Services are mapped to URL paths by specifying a tuple\n (path, service), where path is the path where the service resides, and service is the service class or service factory for creating new instances of the service. For more information about service factories, please see [remote.Service.new_factory](/appengine/docs/legacy/standard/python/tools/protorpc/remote/serviceclass#new_factory).\n\n **Arguments**\n\n services\n : A list of tuples (path, service), where `path` is the path where the service resides, and `service` is the service class or service factory for creating new instances of the service. For more information about service factories, please see [remote.Service.new_factory](/appengine/docs/legacy/standard/python/tools/protorpc/remote/serviceclass#new_factory).\n\n registry_path=DEFAULT_REGISTRY_PATH\n : Path to provide to the registry service. Use None to disable registry service.\n\n Returns a WSGI application with multiple service mappings with an optional registry service.\n\n Raises a `ServiceConfigurationError` when duplicate paths are provided."]]