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
- 用於建立服務新執行個體的服務類別或服務工廠。如要進一步瞭解服務 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 是指用於建立服務新執行個體的服務類別或服務 Factory。如要進一步瞭解服務 Factory,請參閱 remote.Service.new_factory。引數
- services
- 元組 (路徑、服務) 清單,其中
path
是服務所在的路徑,而 service
是用於建立服務新執行個體的服務類別或服務工廠。如要進一步瞭解服務 Factory,請參閱 remote.Service.new_factory。
- registry_path=DEFAULT_REGISTRY_PATH
- 提供給登錄檔服務的路徑。使用 None 即可停用登錄服務。
傳回與選用登錄服務具有多個服務對應的 WSGI 應用程式。
提供重複的路徑時,會擲回 ServiceConfigurationError
。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-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"]],["上次更新時間:2025-08-04 (世界標準時間)。"],[[["This module provides tools to publish Google Protocol RPC services as WSGI applications."],["The `service_mapping` function creates a WSGI application for a single RPC service, using a service factory or class to instantiate the service."],["The `service_mappings` function enables the creation of a WSGI application that hosts multiple services, each mapped to a specific URL path."],["Both functions allow the use of service factories for the creation of service instances."],["The `service_mappings` function can include an optional registry service and will raise a `ServiceConfigurationError` if duplicate paths are given."]]],[]]