WebApp-Dienst-Handler
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Diese Funktion ist veraltet. Sie sollten die neuere WSGI-Dienstbibliothek verwenden, um den Dienst als eine WSGI-Anwendung zu veröffentlichen.
Dieses Modul enthält Klassen, die einen Google Protocol RPC-Dienst mithilfe des App Engine-Web-App-Frameworks veröffentlichen.
Das protorpc.webapp.service_handlers
-Paket bietet folgende Funktionen:
- service_mapping(services, registry_path=DEFAULT_REGISTRY_PATH)
-
Erstellt eine Dienstzuordnung für die Verwendung mit webapp.
Erstellt eine grundlegende Standardkonfiguration und Registrierung für Google Protocol RPC-Dienste. Jeder Dienst, der in der Dienstzuordnung aufgeführt ist, verfügt über eine für ihn erstellte standardmäßige Dienst-Handler-Factory.
Bei der Liste der Zuordnungen kann es sich um einen expliziten Pfad zur Dienstzuordnung oder einfach nur um Dienste handeln. Falls es sich bei Zuordnungen einfach um Dienste handelt, werden sie automatisch ihrem Standardnamen zugeordnet. Beispiel:
from protorpc import remote
from protorpc.webapp import service_handlers
package = 'my_package'
class MyService(remote.Service):
...
service_handlers.service_mapping(
[('/my_path', MyService), # Maps to /my_path
MyService, # Maps to /my_package/MyService
])
Dienste werden URL-Pfaden in der Regel durch Angeben eines Tupels (Pfad, Dienst) zugeordnet, wobei es sich beim Pfad um den Pfad handelt, unter dem sich der Dienst befindet, und beim Dienst um die Dienstklasse oder Dienst-Factory zum Erstellen neuer Instanzen des Diensts. Weitere Informationen zu Dienst-Factories finden Sie unter remote.Service.new_factory.
Falls kein Tupel und daher kein Pfad angegeben ist, wird ein Standardpfad mithilfe des vollqualifizierten Dienstnamens berechnet, dessen einzelne Elemente durch ein URL-Pfadtrennzeichen und nicht durch ein "."-Zeichen getrennt sind.
Argumente
- services
- Ein Tupel (Pfad, Dienst), wobei es sich bei
path
um den Pfad handelt, unter dem sich der Dienst befindet, und bei service
um die Dienstklasse oder Dienst-Factory zum Erstellen neuer Instanzen des Dienstes. Weitere Informationen zu Dienst-Factories finden Sie unter remote.Service.new_factory.
- registry_path=DEFAULT_REGISTRY_PATH
- Pfad, der für den Registrierungsdienst bereitzustellen ist. Verwenden Sie "None", um den Registrierungsdienst zu deaktivieren.
Gibt eine Liste von Tupeln zurück, die eine Zuordnung von Request-Handlern definieren, die mit einer WebApp-Anwendung kompatibel sind.
Gibt einen ServiceConfigurationError aus, wenn doppelte Pfade angegeben werden.
- run_services(services, registry_path=DEFAULT_REGISTRY_PATH)
-
Verarbeitet CGI-Anfragen mithilfe von Dienstzuordnungen.
Argumente
- services
- Ein Tupel (Pfad, Dienst), wobei es sich bei
path
um den Pfad handelt, unter dem sich der Dienst befindet, und bei service
um die Dienstklasse oder Dienst-Factory zum Erstellen neuer Instanzen des Dienstes. Weitere Informationen zu Dienst-Factories finden Sie unter remote.Service.new_factory.
- registry_path=DEFAULT_REGISTRY_PATH
- Pfad, der für den Registrierungsdienst bereitzustellen ist. Verwenden Sie "None", um den Registrierungsdienst zu deaktivieren.
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
Zuletzt aktualisiert: 2025-09-04 (UTC).
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-04 (UTC)."],[[["\u003cp\u003eThis feature is deprecated, and users should transition to the WSGI Service Library for publishing services as WSGI applications.\u003c/p\u003e\n"],["\u003cp\u003eThe module contains classes for publishing Google Protocol RPC services using the App Engine Webapp framework.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eservice_mapping\u003c/code\u003e creates a services mapping for webapp, defining paths and service classes or factories for each service, allowing for both explicit and default path mappings.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003erun_services\u003c/code\u003e handles CGI requests using the service mapping defined, taking services and registry path as arguments.\u003c/p\u003e\n"],["\u003cp\u003eServices can be mapped to a user specified URL path or to a default path based on their fully qualified name, using the \u003ccode\u003eservice_mapping\u003c/code\u003e function.\u003c/p\u003e\n"]]],[],null,["# WebApp Service Handlers\n\nThis feature is deprecated. You should use the newer [WSGI Service Library](/appengine/docs/legacy/standard/python/tools/protorpc/wsgi) to publish the service as a WSGI application.\n\nThis module contains classes that publish a Google Protocol RPC service using the App Engine Webapp framework.\n\nThe `protorpc.webapp.service_handlers` package provides the following functions:\n\nservice_mapping(services, registry_path=DEFAULT_REGISTRY_PATH)\n\n: Creates a services mapping for use with webapp.\n\n Creates basic default configuration and registration for Google Protocol RPC services. Each service listed in the service mapping has a standard service handler factory created for it.\n\n The list of mappings can either be an explicit path to service mapping or just services. If mappings are just services, they will automatically be mapped to their default name. For example: \n\n ```python\n from protorpc import remote\n from protorpc.webapp import service_handlers\n\n package = 'my_package'\n\n class MyService(remote.Service):\n ...\n\n service_handlers.service_mapping(\n [('/my_path', MyService), # Maps to /my_path\n MyService, # Maps to /my_package/MyService\n ])\n ```\n\n Normally, 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 If no tuple is provided, and therefore no path specified, a default path\n is calculated by using the fully qualified service name using a URL path\n separator for each of its components instead of a '.'.\n **Arguments**\n\n services\n : A tuple (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\n registry service.\n\n Returns a list of tuples defining a mapping of request handlers compatible with a [WebApp](/appengine/docs/legacy/standard/python/tools/webapp) application.\n\n Raises a ServiceConfigurationError when duplicate paths are provided.\n\nrun_services(services, registry_path=DEFAULT_REGISTRY_PATH)\n\n: Handles CGI request using service mapping.\n\n **Arguments**\n\n services\n : A tuple (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\n registry service."]]