Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
tornado.web.Application Class Reference
Inheritance diagram for tornado.web.Application:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def __call__
def __init__
def add_handlers
def add_transform
def listen
def log_request
def reverse_url

Public Attributes

 default_host
 handlers
 named_handlers
 settings
 transforms
 ui_methods
 ui_modules

Private Member Functions

def _get_host_handlers
def _load_ui_methods
def _load_ui_modules

Private Attributes

 _wsgi

Detailed Description

A collection of request handlers that make up a web application.

Instances of this class are callable and can be passed directly to
HTTPServer to serve the application::

    application = web.Application([
        (r"/", MainPageHandler),
    ])
    http_server = httpserver.HTTPServer(application)
    http_server.listen(8080)
    ioloop.IOLoop.instance().start()

The constructor for this class takes in a list of URLSpec objects
or (regexp, request_class) tuples. When we receive requests, we
iterate over the list in order and instantiate an instance of the
first request class whose regexp matches the request path.

Each tuple can contain an optional third element, which should be a
dictionary if it is present. That dictionary is passed as keyword
arguments to the contructor of the handler. This pattern is used
for the StaticFileHandler below (note that a StaticFileHandler
can be installed automatically with the static_path setting described
below)::

    application = web.Application([
        (r"/static/(.*)", web.StaticFileHandler, {"path": "/var/www"}),
    ])

We support virtual hosts with the add_handlers method, which takes in
a host regular expression as the first argument::

    application.add_handlers(r"www\.myhost\.com", [
        (r"/article/([0-9]+)", ArticleHandler),
    ])

You can serve static files by sending the static_path setting as a
keyword argument. We will serve those files from the /static/ URI
(this is configurable with the static_url_prefix setting),
and we will serve /favicon.ico and /robots.txt from the same directory.
A custom subclass of StaticFileHandler can be specified with the
static_handler_class setting.

.. attribute:: settings

   Additonal keyword arguments passed to the constructor are saved in the
   `settings` dictionary, and are often referred to in documentation as
   "application settings".

Definition at line 1166 of file web.py.


Constructor & Destructor Documentation

def tornado.web.Application.__init__ (   self,
  handlers = None,
  default_host = "",
  transforms = None,
  wsgi = False,
  settings 
)

Definition at line 1215 of file web.py.


Member Function Documentation

def tornado.web.Application.__call__ (   self,
  request 
)
Called by HTTPServer to execute the request.

Definition at line 1366 of file web.py.

def tornado.web.Application._get_host_handlers (   self,
  request 
) [private]

Definition at line 1325 of file web.py.

def tornado.web.Application._load_ui_methods (   self,
  methods 
) [private]

Definition at line 1337 of file web.py.

def tornado.web.Application._load_ui_modules (   self,
  modules 
) [private]

Definition at line 1350 of file web.py.

def tornado.web.Application.add_handlers (   self,
  host_pattern,
  host_handlers 
)
Appends the given handlers to our handler list.

Note that host patterns are processed sequentially in the
order they were added, and only the first matching pattern is
used.  This means that all handlers for a given host must be
added in a single add_handlers call.

Definition at line 1276 of file web.py.

def tornado.web.Application.add_transform (   self,
  transform_class 
)
Adds the given OutputTransform to our transform list.

Definition at line 1321 of file web.py.

def tornado.web.Application.listen (   self,
  port,
  address = "",
  kwargs 
)
Starts an HTTP server for this application on the given port.

This is a convenience alias for creating an HTTPServer object
and calling its listen method.  Keyword arguments not
supported by HTTPServer.listen are passed to the HTTPServer
constructor.  For advanced uses (e.g. preforking), do not use
this method; create an HTTPServer and call its bind/start
methods directly.

Note that after calling this method you still need to call
IOLoop.instance().start() to start the server.

Definition at line 1257 of file web.py.

def tornado.web.Application.log_request (   self,
  handler 
)
Writes a completed HTTP request to the logs.

By default writes to the python root logger.  To change
this behavior either subclass Application and override this method,
or pass a function in the application settings dictionary as
'log_function'.

Definition at line 1428 of file web.py.

def tornado.web.Application.reverse_url (   self,
  name,
  args 
)
Returns a URL path for handler named `name`

The handler must be added to the application as a named URLSpec.

Args will be substituted for capturing groups in the URLSpec regex.
They will be converted to strings if necessary, encoded as utf8,
and url-escaped.

Definition at line 1415 of file web.py.


Member Data Documentation

Definition at line 1215 of file web.py.

Definition at line 1215 of file web.py.

Definition at line 1215 of file web.py.

Definition at line 1215 of file web.py.

Definition at line 1215 of file web.py.

Definition at line 1215 of file web.py.

Definition at line 1215 of file web.py.

Definition at line 1215 of file web.py.


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


rosbridge_server
Author(s): Jonathan Mace
autogenerated on Mon Oct 6 2014 06:58:15