當前位置: 首頁>>代碼示例>>Python>>正文


Python endpoints.method方法代碼示例

本文整理匯總了Python中endpoints.method方法的典型用法代碼示例。如果您正苦於以下問題:Python endpoints.method方法的具體用法?Python endpoints.method怎麽用?Python endpoints.method使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在endpoints的用法示例。


在下文中一共展示了endpoints.method方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: list_greetings

# 需要導入模塊: import endpoints [as 別名]
# 或者: from endpoints import method [as 別名]
def list_greetings(self, unused_request):
        return STORED_GREETINGS

    # ResourceContainers are used to encapsuate a request body and url
    # parameters. This one is used to represent the Greeting ID for the
    # greeting_get method. 
開發者ID:codesdk,項目名稱:appbackendapi,代碼行數:8,代碼來源:main.py

示例2: __init__

# 需要導入模塊: import endpoints [as 別名]
# 或者: from endpoints import method [as 別名]
def __init__(self, api_services, **kwargs):
    """Initialize an _ApiServer instance.

    The primary function of this method is to set up the WSGIApplication
    instance for the service handlers described by the services passed in.
    Additionally, it registers each API in ApiConfigRegistry for later use
    in the BackendService.getApiConfigs() (API config enumeration service).

    Args:
      api_services: List of protorpc.remote.Service classes implementing the API
        or a list of _ApiDecorator instances that decorate the service classes
        for an API.
      **kwargs: Passed through to protorpc.wsgi.service.service_handlers except:
        protocols - ProtoRPC protocols are not supported, and are disallowed.

    Raises:
      TypeError: if protocols are configured (this feature is not supported).
      ApiConfigurationError: if there's a problem with the API config.
    """
    self.base_paths = set()

    for entry in api_services[:]:
      # pylint: disable=protected-access
      if isinstance(entry, api_config._ApiDecorator):
        api_services.remove(entry)
        api_services.extend(entry.get_api_classes())

    # Record the API services for quick discovery doc generation
    self.api_services = api_services

    # Record the base paths
    for entry in api_services:
      self.base_paths.add(entry.api_info.base_path)

    self.api_config_registry = api_backend_service.ApiConfigRegistry()
    self.api_name_version_map = self.__create_name_version_map(api_services)
    protorpc_services = self.__register_services(self.api_name_version_map,
                                                 self.api_config_registry)

    # Disallow protocol configuration for now, Lily is json-only.
    if 'protocols' in kwargs:
      raise TypeError('__init__() got an unexpected keyword argument '
                      "'protocols'")
    protocols = remote.Protocols()
    protocols.add_protocol(self.__PROTOJSON, 'protojson')
    remote.Protocols.set_default(protocols)

    # This variable is not used in Endpoints 1.1, but let's pop it out here
    # so it doesn't result in an unexpected keyword argument downstream.
    kwargs.pop('restricted', None)

    self.service_app = wsgi_service.service_mappings(protorpc_services,
                                                     **kwargs) 
開發者ID:cloudendpoints,項目名稱:endpoints-python,代碼行數:55,代碼來源:apiserving.py

示例3: api_server

# 需要導入模塊: import endpoints [as 別名]
# 或者: from endpoints import method [as 別名]
def api_server(api_services, **kwargs):
  """Create an api_server.

  The primary function of this method is to set up the WSGIApplication
  instance for the service handlers described by the services passed in.
  Additionally, it registers each API in ApiConfigRegistry for later use
  in the BackendService.getApiConfigs() (API config enumeration service).
  It also configures service control.

  Args:
    api_services: List of protorpc.remote.Service classes implementing the API
      or a list of _ApiDecorator instances that decorate the service classes
      for an API.
    **kwargs: Passed through to protorpc.wsgi.service.service_handlers except:
      protocols - ProtoRPC protocols are not supported, and are disallowed.

  Returns:
    A new WSGIApplication that serves the API backend and config registry.

  Raises:
    TypeError: if protocols are configured (this feature is not supported).
  """
  # Disallow protocol configuration for now, Lily is json-only.
  if 'protocols' in kwargs:
    raise TypeError("__init__() got an unexpected keyword argument 'protocols'")

  # Construct the api serving app
  apis_app = _ApiServer(api_services, **kwargs)
  dispatcher = endpoints_dispatcher.EndpointsDispatcherMiddleware(apis_app)

  # Determine the service name
  service_name = os.environ.get('ENDPOINTS_SERVICE_NAME')
  if not service_name:
    _logger.warn('Did not specify the ENDPOINTS_SERVICE_NAME environment'
                 ' variable so service control is disabled.  Please specify'
                 ' the name of service in ENDPOINTS_SERVICE_NAME to enable'
                 ' it.')
    return dispatcher

  # If we're using a local server, just return the dispatcher now to bypass
  # control client.
  if control_wsgi.running_on_devserver():
    _logger.warn('Running on local devserver, so service control is disabled.')
    return dispatcher

  # The DEFAULT 'config' should be tuned so that it's always OK for python
  # App Engine workloads.  The config can be adjusted, but that's probably
  # unnecessary on App Engine.
  controller = control_client.Loaders.DEFAULT.load(service_name)

  # Start the GAE background thread that powers the control client's cache.
  control_client.use_gae_thread()
  controller.start()

  return control_wsgi.add_all(
      dispatcher,
      app_identity.get_application_id(),
      controller) 
開發者ID:cloudendpoints,項目名稱:endpoints-python,代碼行數:60,代碼來源:apiserving.py


注:本文中的endpoints.method方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。