Controladores de servicios webApp
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Esta característica está obsoleta. Debes usar la Biblioteca de servicio WSGI más nueva para publicar el servicio como una aplicación de WSGI.
Este módulo contiene clases que publican un servicio de RPC del protocolo de Google mediante el marco de trabajo WebApp de App Engine.
El paquete protorpc.webapp.service_handlers
proporciona las siguientes funciones:
- service_mapping(servicios, registry_path=DEFAULT_REGISTRY_PATH)
-
Crea una asignación de servicios para que se use con webapp.
Crea un registro y una configuración predeterminada básica para los servicios RPC de protocolo de Google. Cada servicio enumerado en la asignación de servicio tiene una fábrica de controlador de servicio estándar.
La lista de asignaciones puede ser una ruta explícita a una asignación de servicio, o bien solo servicios. Si las asignaciones son solo servicios, se asignarán de manera automática a su nombre predeterminado. Por ejemplo:
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
])
Normalmente, los servicios se asignan a las rutas de URL mediante la especificación de una tupla (ruta, servicio), en la que la ruta es aquella donde reside el servicio y el servicio es la clase de servicio o la fábrica de servicios para crear nuevas instancias del servicio. Para obtener más información sobre las fábricas de servicios, consulta remote.Service.new_factory.
Si no se proporciona una tupla y, por lo tanto, no se especifica una ruta, se calcula una ruta predeterminada con un nombre de servicio completamente calificado mediante un separador de ruta de URL para cada uno de los componentes, en lugar de “.”.
Argumentos
- services
- Una tupla (ruta, servicio), en la que
path
es la ruta donde reside el servicio y service
es la clase de servicio o fábrica de servicios para crear nuevas instancias del servicio. Para obtener más información sobre las fábricas de servicios, consulta remote.Service.new_factory.
- registry_path=DEFAULT_REGISTRY_PATH
- Ruta para proporcionar al servicio de registro. Usa Ninguno para inhabilitar el servicio de registro.
Muestra una lista de tuplas que definen una asignación de controladores de solicitud compatible con una aplicación de WebApp.
Provoca un ServiceConfigurationError al proporcionarse rutas de acceso duplicadas.
- run_services(servicios, registry_path=DEFAULT_REGISTRY_PATH)
-
Maneja una solicitud de CGI mediante asignaciones de servicio.
Argumentos- services
- Una tupla (ruta, servicio), en la que
path
es la ruta donde reside el servicio y service
es la clase de servicio o fábrica de servicios para crear nuevas instancias del servicio. Para obtener más información sobre las fábricas de servicios, consulta remote.Service.new_factory.
- registry_path=DEFAULT_REGISTRY_PATH
- Ruta para proporcionar al servicio de registro. Usa Ninguno para inhabilitar el servicio de registro.
Salvo que se indique lo contrario, el contenido de esta página está sujeto a la licencia Atribución 4.0 de Creative Commons, y los ejemplos de código están sujetos a la licencia Apache 2.0. Para obtener más información, consulta las políticas del sitio de Google Developers. Java es una marca registrada de Oracle o sus afiliados.
Última actualización: 2025-09-04 (UTC)
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 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."]]