App Engine Python SDK  v1.6.9 rev.445
The Python runtime is available as an experimental Preview feature.
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
google.appengine.tools.dev_appserver_apiserver.ApiConfigManager Class Reference
Inheritance diagram for google.appengine.tools.dev_appserver_apiserver.ApiConfigManager:

Public Member Functions

def __init__
 
def ParseApiConfigResponse
 
def SaveRpcMethod
 
def LookupRpcMethod
 
def SaveRestMethod
 
def LookupRestMethod
 

Static Public Member Functions

def HasSpiEndpoint
 
def CompilePathPattern
 

Public Attributes

 configs
 

Detailed Description

Manages loading api configs and method lookup.

Member Function Documentation

def google.appengine.tools.dev_appserver_apiserver.ApiConfigManager.CompilePathPattern (   pattern)
static
Generates a compiled regex pattern for a path pattern.

e.g. '/{!name}/{!version}/notes/{id}'
returns re.compile(r'/([^:/?#\[\]{}]*)'
               r'/([^:/?#\[\]{}]*)'
               r'/notes/(?P<id>[^:/?#\[\]{}]*)')
Note in this example that !name and !version are reserved variable names
used to match the API name and version that should not be migrated into the
method argument namespace.  As such they are not named in the regex, so
groupdict() excludes them.

Args:
  pattern: parameterized path pattern to be checked

Returns:
  compiled regex to match this path pattern
def google.appengine.tools.dev_appserver_apiserver.ApiConfigManager.HasSpiEndpoint (   config)
static
Checks if an SPI is registered with this App.

Args:
  config: Parsed app.yaml as an appinfo proto.

Returns:
  True if any handler is registered for (/_ah/spi/.*).
def google.appengine.tools.dev_appserver_apiserver.ApiConfigManager.LookupRestMethod (   self,
  path,
  http_method 
)
Look up the rest method at call time.

The method is looked up in self._rest_methods, the list it is saved
in for SaveRestMethod.

Args:
  path: Path from the URL of the request.
  http_method: HTTP method of the request.

Returns:
  Tuple of (<method name>, <method>, <params>)
  Where:
<method name> is the string name of the method that was matched.
<method> is the descriptor as specified in the API configuration. -and-
<params> is a dict of path parameters matched in the rest request.
def google.appengine.tools.dev_appserver_apiserver.ApiConfigManager.LookupRpcMethod (   self,
  method_name,
  version 
)
Lookup the JsonRPC method at call time.

The method is looked up in self._rpc_method_dict, the dictionary that
it is saved in for SaveRpcMethod().

Args:
  method_name: String name of the method
  version: String version of the API

Returns:
  Method descriptor as specified in the API configuration.
def google.appengine.tools.dev_appserver_apiserver.ApiConfigManager.ParseApiConfigResponse (   self,
  body 
)
Parses a json api config and registers methods for dispatch.

Side effects:
  Parses method name, etc for all methods and updates the indexing
  datastructures with the information.

Args:
  body: body of getApiConfigs response
def google.appengine.tools.dev_appserver_apiserver.ApiConfigManager.SaveRestMethod (   self,
  method_name,
  version,
  method 
)
Store Rest api methods in a list for lookup at call time.

The list is self._rest_methods, a list of tuples:
  [(<compiled_path>, <path_pattern>, <method_dict>), ...]
where:
  <compiled_path> is a compiled regex to match against the incoming URL
  <path_pattern> is a string representing the original path pattern,
checked on insertion to prevent duplicates.     -and-
  <method_dict> is a dict (httpMethod, apiVersion) => (method_name, method)

This structure is a bit complex, it supports use in two contexts:
  Creation time:
- SaveRestMethod is called repeatedly, each method will have a path,
  which we want to be compiled for fast lookup at call time
- We want to prevent duplicate incoming path patterns, so store the
  un-compiled path, not counting on a compiled regex being a stable
  comparison as it is not documented as being stable for this use.
- Need to store the method that will be mapped at calltime.
- Different methods may have the same path but different http method.
  and/or API versions.
  Call time:
- Quickly scan through the list attempting .match(path) on each
  compiled regex to find the path that matches.
- When a path is matched, look up the API version and method from the
  request and get the method name and method config for the matching
  API method and method name.

Args:
  method_name: Name of the API method
  version: Version of the API
  method: method descriptor (as in the api config file).
def google.appengine.tools.dev_appserver_apiserver.ApiConfigManager.SaveRpcMethod (   self,
  method_name,
  version,
  method 
)
Store JsonRpc api methods in a map for lookup at call time.

(rpcMethodName, apiVersion) => method.

Args:
  method_name: Name of the API method
  version: Version of the API
  method: method descriptor (as in the api config file).

The documentation for this class was generated from the following file: