Back to index

moin  1.9.0~rc2
Classes | Functions | Variables
MoinMoin.support.flup.server.ajp_fork Namespace Reference

Classes

class  WSGIServer

Functions

def test_app

Variables

string __author__ = 'Allan Saddi <allan@saddi.com>'
string __version__ = '$Revision$'
list __all__ = ['WSGIServer']
tuple test_app = validate.validator(test_app)
tuple bindAddress = ('', 8009)
tuple loggingLevel = logging.DEBUG).run()

Detailed Description

.. highlight:: python
   :linenothreshold: 5

.. highlight:: bash
   :linenothreshold: 5

ajp - an AJP 1.3/WSGI gateway.

:copyright: Copyright (c) 2005, 2006 Allan Saddi <allan@saddi.com>
  All rights reserved.
:license:

 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions
 are met:

 1. Redistributions of source code must retain the above copyright
    notice, this list of conditions and the following disclaimer.
 2. Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimer in the
    documentation and/or other materials provided with the distribution.

 THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS **AS IS** AND
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 SUCH DAMAGE.

For more information about AJP and AJP connectors for your web server, see
http://jakarta.apache.org/tomcat/connectors-doc/.

For more information about the Web Server Gateway Interface, see
http://www.python.org/peps/pep-0333.html.

Example usage:

  #!/usr/bin/env python
  import sys
  from myapplication import app # Assume app is your WSGI application object
  from ajp import WSGIServer
  ret = WSGIServer(app).run()
  sys.exit(ret and 42 or 0)

See the documentation for WSGIServer for more information.

About the bit of logic at the end:
Upon receiving SIGHUP, the python script will exit with status code 42. This
can be used by a wrapper script to determine if the python script should be
re-run. When a SIGINT or SIGTERM is received, the script exits with status
code 0, possibly indicating a normal exit.

Example wrapper script::

  #!/bin/sh
  STATUS=42
  while test $STATUS -eq 42; do
    python "$@" that_script_above.py
    STATUS=$?
  done

Example workers.properties (for mod_jk)::

  worker.list=foo
  worker.foo.port=8009
  worker.foo.host=localhost
  worker.foo.type=ajp13

Example httpd.conf (for mod_jk)::

  JkWorkersFile /path/to/workers.properties
  JkMount /* foo

Note that if you mount your ajp application anywhere but the root ("/"), you
SHOULD specifiy scriptName to the WSGIServer constructor. This will ensure
that SCRIPT_NAME/PATH_INFO are correctly deduced.

Function Documentation

def MoinMoin.support.flup.server.ajp_fork.test_app (   environ,
  start_response 
)
Probably not the most efficient example.

Definition at line 170 of file ajp_fork.py.

00170 
00171     def test_app(environ, start_response):
00172         """Probably not the most efficient example."""
00173         import cgi
00174         start_response('200 OK', [('Content-Type', 'text/html')])
00175         yield '<html><head><title>Hello World!</title></head>\n' \
00176               '<body>\n' \
00177               '<p>Hello World!</p>\n' \
00178               '<table border="1">'
00179         names = environ.keys()
00180         names.sort()
00181         for name in names:
00182             yield '<tr><td>%s</td><td>%s</td></tr>\n' % (
00183                 name, cgi.escape(`environ[name]`))
00184 
00185         form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ,
00186                                 keep_blank_values=1)
00187         if form.list:
00188             yield '<tr><th colspan="2">Form data</th></tr>'
00189 
00190         for field in form.list:
00191             yield '<tr><td>%s</td><td>%s</td></tr>\n' % (
00192                 field.name, field.value)
00193 
00194         yield '</table>\n' \
00195               '</body></html>\n'


Variable Documentation

Definition at line 94 of file ajp_fork.py.

string MoinMoin.support.flup.server.ajp_fork.__author__ = 'Allan Saddi <allan@saddi.com>'

Definition at line 85 of file ajp_fork.py.

Definition at line 86 of file ajp_fork.py.

Definition at line 200 of file ajp_fork.py.

Definition at line 201 of file ajp_fork.py.

Definition at line 197 of file ajp_fork.py.