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

Package wsgiserver

source code

A high-speed, production ready, thread pooled, generic WSGI server.

Simplest example on how to use this module directly
(without using CherryPy's application machinery):

    from cherrypy import wsgiserver
    
    def my_crazy_app(environ, start_response):
        status = '200 OK'
        response_headers = [('Content-type','text/plain')]
        start_response(status, response_headers)
        return ['Hello world!
']
    
    # Here we set our application to the script_name '/' 
    wsgi_apps = [('/', my_crazy_app)]
    
    server = wsgiserver.CherryPyWSGIServer(('localhost', 8070), wsgi_apps,
                                           server_name='localhost')
    
    # Want SSL support? Just set these attributes
    # server.ssl_certificate = <filename>
    # server.ssl_private_key = <filename>
    
    if __name__ == '__main__':
        try:
            server.start()
        except KeyboardInterrupt:
            server.stop()

This won't call the CherryPy engine (application side) at all, only the
WSGI server, which is independant from the rest of CherryPy. Don't
let the name "CherryPyWSGIServer" throw you; the name merely reflects
its origin, not it's coupling.

The CherryPy WSGI server can serve as many WSGI applications
as you want in one instance:

    wsgi_apps = [('/', my_crazy_app), ('/blog', my_blog_app)]

Classes [hide private]
  HTTPRequest
An HTTP Request (and response).
  NoSSLError
Exception raised when a client speaks HTTP to an HTTPS socket.
  SSL_fileobject
Faux file object attached to a socket object.
  HTTPConnection
An HTTP connection (active socket).
  WorkerThread
Thread which continuously polls a Queue for Connection objects.
  SSLConnection
A thread-safe wrapper for an SSL.Connection.
  CherryPyWSGIServer
An HTTP server for WSGI.
Functions [hide private]
 
_ssl_wrap_method(method, is_reader=False)
Wrap the given method with SSL error-trapping.
source code
 
format_exc(limit=None)
Like print_exc() but return a string.
source code
Variables [hide private]
  quoted_slash = re.compile(r'(?i)%2F')
  SSL = None
hash(x)
  socket_errors_to_ignore = [32, 104, 110, 111, 112, 113, 'timed...
  comma_separated_headers = ['ACCEPT', 'ACCEPT-CHARSET', 'ACCEPT...
  _SHUTDOWNREQUEST = None
hash(x)
  _ = 'WSAETIMEDOUT'
  __package__ = 'cherrypy.wsgiserver'
Function Details [hide private]

_ssl_wrap_method(method, is_reader=False)

source code 
Wrap the given method with SSL error-trapping.

is_reader: if False (the default), EOF errors will be raised.
    If True, EOF errors will return "" (to emulate normal sockets).

format_exc(limit=None)

source code 

Like print_exc() but return a string. Backport for Python 2.3.


Variables Details [hide private]

socket_errors_to_ignore

Value:
[32, 104, 110, 111, 112, 113, 'timed out']

comma_separated_headers

Value:
['ACCEPT',
 'ACCEPT-CHARSET',
 'ACCEPT-ENCODING',
 'ACCEPT-LANGUAGE',
 'ACCEPT-RANGES',
 'ALLOW',
 'CACHE-CONTROL',
 'CONNECTION',
...