Bibliothèque de services WSGI
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Ce module contient des classes qui publient un service Google Protocol RPC en tant qu'application WSGI.
Le package protorpc.wsgi.service
comprend les fonctions suivantes :
- service_mapping(service_factory, service_path=r'.*', protocols=None)
-
Crée une application WSGI qui gère un seul mappage de service Google Protocol RPC.
Arguments
- service_factory
- Classe de services ou fabrique de services pour la création de nouvelles instances du service. Pour en savoir plus sur les fabriques de services, consultez la section remote.Service.new_factory.
- service_path=r'.*'
- Chemin correspondant au chemin d'accès au service.
- protocols=None
- Instance de remote.Protocols qui configure les protocoles acceptés sur le serveur.
Renvoie une application WSGI qui gère un seul mappage de service Google Protocol RPC.
- service_mappings(services, registry_path=DEFAULT_REGISTRY_PATH)
-
Crée une application WSGI avec plusieurs mappages de services avec un service de registre facultatif. Exemple :
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
])
En principe, les services sont mappés aux chemins d'URL par l'indication d'un tuple (chemin, service), où le chemin correspond au chemin d'accès au service, et le service, à la fabrique ou à la classe de services de création de nouvelles instances du service. Pour en savoir plus sur les fabriques de services, consultez la section remote.Service.new_factory.
Arguments
- services
- Liste de tuples (chemin, service), où
path
correspond au chemin d'accès au service et service
, à la fabrique ou à la classe de services de création de nouvelles instances du service. Pour en savoir plus sur les fabriques de services, consultez la section remote.Service.new_factory.
- registry_path=DEFAULT_REGISTRY_PATH
- Chemin d'accès à fournir au service de registre. La valeur None permet de désactiver le service de registre.
Renvoie une application WSGI avec plusieurs mappages de services avec un service de registre facultatif.
Génère une erreur ServiceConfigurationError
lorsqu'il existe des chemins en double.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/04 (UTC)."],[[["\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."]]