Package cherrypy
[hide private]
[frames] | no frames]

Package cherrypy

source code

CherryPy is a pythonic, object-oriented HTTP framework.


CherryPy consists of not one, but four separate API layers.

The APPLICATION LAYER is the simplest. CherryPy applications are written as
a tree of classes and methods, where each branch in the tree corresponds to
a branch in the URL path. Each method is a 'page handler', which receives
GET and POST params as keyword arguments, and returns or yields the (HTML)
body of the response. The special method name 'index' is used for paths
that end in a slash, and the special method name 'default' is used to
handle multiple paths via a single handler. This layer also includes:

 * the 'exposed' attribute (and cherrypy.expose)
 * cherrypy.quickstart()
 * _cp_config attributes
 * cherrypy.tools (including cherrypy.session)
 * cherrypy.url()

The ENVIRONMENT LAYER is used by developers at all levels. It provides
information about the current request and response, plus the application
and server environment, via a (default) set of top-level objects:

 * cherrypy.request
 * cherrypy.response
 * cherrypy.engine
 * cherrypy.server
 * cherrypy.tree
 * cherrypy.config
 * cherrypy.thread_data
 * cherrypy.log
 * cherrypy.HTTPError, NotFound, and HTTPRedirect
 * cherrypy.lib

The EXTENSION LAYER allows advanced users to construct and share their own
plugins. It consists of:

 * Hook API
 * Tool API
 * Toolbox API
 * Dispatch API
 * Config Namespace API

Finally, there is the CORE LAYER, which uses the core API's to construct
the default components which are available at higher layers. You can think
of the default components as the 'reference implementation' for CherryPy.
Megaframeworks (and advanced users) may replace the default components
with customized or extended components. The core API's are:

 * Application API
 * Engine API
 * Request API
 * Server API
 * WSGI API

These API's are described in the CherryPy specification:
http://www.cherrypy.org/wiki/CherryPySpec




Version: 3.0.2

Submodules [hide private]

Classes [hide private]
  _AttributeDocstrings
Metaclass for declaring docstrings for class attributes.
  _Serving
An interface for registering request and response objects.
  _ThreadLocalProxy
  _ThreadData
A container for thread-specific data.
  _GlobalLogManager
Functions [hide private]
 
quickstart(root, script_name='', config=None)
Mount the given root, start the engine and builtin server, then block.
source code
 
_cherrypy_pydoc_resolve(thing, forceload=0)
Given an object or a path to an object, get the object and its name.
source code
 
expose(func=None, alias=None)
Expose the function, optionally providing an alias or set of aliases.
source code
 
url(path='', qs='', script_name=None, base=None, relative=False)
Create an absolute URL for the given path.
source code
Variables [hide private]
  engine = _cpengine.Engine()
  tools = _cptools.default_toolbox
  tree = _cptree.Tree()
  server = _cpserver.Server()
  _serving = _Serving()
  serving = _Serving()
  request = _ThreadLocalProxy('request')
  response = _ThreadLocalProxy('response')
  thread_data = _ThreadData()
  log = _GlobalLogManager()
  _global_conf_alias = {'request.show_tracebacks': False, 'log.s...
  config = {'request.show_tracebacks': False, 'log.screen': Fals...
  checker = _cpchecker.Checker()
Function Details [hide private]

url(path='', qs='', script_name=None, base=None, relative=False)

source code 
Create an absolute URL for the given path.

If 'path' starts with a slash ('/'), this will return
    (base + script_name + path + qs).
If it does not start with a slash, this returns
    (base + script_name [+ request.path_info] + path + qs).

If script_name is None, cherrypy.request will be used
to find a script_name, if available.

If base is None, cherrypy.request.base will be used (if available).
Note that you can use cherrypy.tools.proxy to change this.

Finally, note that this function can be used to obtain an absolute URL
for the current request path (minus the querystring) by passing no args.
If you call url(qs=cherrypy.request.query_string), you should get the
original browser URL (assuming no Internal redirections).

If relative is False (the default), the output will be an absolute URL
(usually including the scheme, host, vhost, and script_name).
If relative is True, the output will instead be a URL that is relative
to the current request path, perhaps including '..' atoms.


Variables Details [hide private]

_global_conf_alias

Value:
{'request.show_tracebacks': False, 'log.screen': False, 'checker.on': \
False, 'server.max_request_body_size': 0, 'engine.deadlock_poll_freq':\
 0, 'log.error.file': '', 'engine.autoreload_on': False, 'response.tim\
eout': 0.20000000000000001, 'server.socket_port': 8080, 'environment':\
 'production', 'server.socket_host': 'localhost', 'server.max_request_\
header_size': 0}

config

Value:
{'request.show_tracebacks': False, 'log.screen': False, 'checker.on': \
False, 'server.max_request_body_size': 0, 'engine.deadlock_poll_freq':\
 0, 'log.error.file': '', 'engine.autoreload_on': False, 'response.tim\
eout': 0.20000000000000001, 'server.socket_port': 8080, 'environment':\
 'production', 'server.socket_host': 'localhost', 'server.max_request_\
header_size': 0}