import ashd.proto, ashd.util
def usage(out):
- out.write("usage: ashd-wsgi [-hA] [-p MODPATH] [-l REQLIMIT] HANDLER-MODULE [ARGS...]\n")
+ out.write("usage: ashd-wsgi3 [-hA] [-p MODPATH] [-l REQLIMIT] HANDLER-MODULE [ARGS...]\n")
reqlimit = 0
modwsgi_compat = False
try:
handlermod = __import__(args[0], fromlist = ["dummy"])
except ImportError as exc:
- sys.stderr.write("ashd-wsgi: handler %s not found: %s\n" % (args[0], exc.args[0]))
+ sys.stderr.write("ashd-wsgi3: handler %s not found: %s\n" % (args[0], exc.args[0]))
sys.exit(1)
if not modwsgi_compat:
if not hasattr(handlermod, "wmain"):
- sys.stderr.write("ashd-wsgi: handler %s has no `wmain' function\n" % args[0])
+ sys.stderr.write("ashd-wsgi3: handler %s has no `wmain' function\n" % args[0])
sys.exit(1)
handler = handlermod.wmain(*args[1:])
else:
if not hasattr(handlermod, "application"):
- sys.stderr.write("ashd-wsgi: handler %s has no `application' object\n" % args[0])
+ sys.stderr.write("ashd-wsgi3: handler %s has no `application' object\n" % args[0])
sys.exit(1)
handler = handlermod.application
Python stream object in the `sk' variable. Again, see the ashd(7)
manpage for what to receive and transmit on the response socket.
- Note that instances of this class contain a reference to the live
- socket used for responding to requests, which should be closed
- when you are done with the request. The socket can be closed
- manually by calling the close() method on this
+ Note that all request parts are stored in byte, rather than
+ string, form. The response socket is also opened in binary mode.
+
+ Note also that instances of this class contain a reference to the
+ live socket used for responding to requests, which should be
+ closed when you are done with the request. The socket can be
+ closed manually by calling the close() method on this
object. Alternatively, this class implements the resource-manager
interface, so that it can be used in `with' statements.
"""
req["Content-Type"] returns the value of the content-type
header regardlessly of whether the client specified it as
"Content-Type", "content-type" or "Content-type".
+
+ If the header is given as a (Unicode) string, it is encoded
+ into Ascii for use in matching.
"""
if isinstance(header, str):
header = header.encode("ascii")
string off and returns True. Otherwise, it returns False
without doing anything.
+ If the `match' argument is given as a (Unicode) string, it is
+ encoded into UTF-8.
+
This can be used for simple dispatching. For example:
if req.match("foo/"):
handle(req)
and the `ctype' argument can be used to specify a non-HTML
MIME-type.
- If `body' is a Unicode object, it will be encoded as UTF-8.
+ If `body' is not a byte string, its string representation will be
+ encoded as UTF-8.
For example:
respond(req, "Not found", status = "404 Not Found", ctype = "text/plain")
-ashd-wsgi(1)
-============
+ashd-wsgi3(1)
+=============
NAME
----
-ashd-wsgi - WSGI adapter for ashd(7)
+ashd-wsgi3 - WSGI adapter for ashd(7)
SYNOPSIS
--------
-*ashd-wsgi* [*-hA*] [*-p* 'MODPATH'] [*-l* 'LIMIT'] 'HANDLER-MODULE' ['ARGS'...]
+*ashd-wsgi3* [*-hA*] [*-p* 'MODPATH'] [*-l* 'LIMIT'] 'HANDLER-MODULE' ['ARGS'...]
DESCRIPTION
-----------
-The *ashd-wsgi* handler translates *ashd*(7) requests to WSGI
+The *ashd-wsgi3* handler translates *ashd*(7) requests to WSGI
requests, and passes them to a specified Python handler module. The
precise Python convention for doing so is described in the PROTOCOL
section, below.
-*ashd-wsgi* is a persistent handler, as defined in *ashd*(7). It uses
+*ashd-wsgi3* is a persistent handler, as defined in *ashd*(7). It uses
multithreaded dispatching in a single Python interpreter, which means
that WSGI applications that use it need to be thread-safe, but that
they can also share all Python data structures and global variables
between requests.
-The Python module that *ashd-wsgi* comes with also contains a standard
-handler module, `ashd.wsgidir`, which serves individual WSGI
+The Python module that *ashd-wsgi3* comes with also contains a
+standard handler module, `ashd.wsgidir`, which serves individual WSGI
applications directly from the files in which they reside and as such
makes this program useful as a *dirplex*(1) handler. Please see its
Python documentation for further details.
-*ashd-wsgi* requires the `ashd.proto` and `ashd.util` modules, which
+*ashd-wsgi3* requires the `ashd.proto` and `ashd.util` modules, which
are only available for CPython. If you want to use some other Python
implementation instead, you may want to use the *scgi-wsgi*(1) program
instead, along with *callscgi*(1).
*-p* 'MODPATH'::
Prepend 'MODPATH' to Python's `sys.path`; can be given multiple
- times. Note that the working directory of *ashd-wsgi* is not
+ times. Note that the working directory of *ashd-wsgi3* is not
on Python's module path by default, so if you want to use a
module in that directory, you will need to specify "`-p .`".
Allow at most 'LIMIT' requests to run concurrently. If a new
request is made when 'LIMIT' requests are executing, the new
request will wait up to ten seconds for one of them to
- complete; if none does, *ashd-wsgi* will assume that the
+ complete; if none does, *ashd-wsgi3* will assume that the
process is foobar and *abort*(3).
PROTOCOL
--------
-When starting, *ashd-wsgi* will attempt to import the module named by
+When starting, *ashd-wsgi3* will attempt to import the module named by
'HANDLER-MODULE', look for an object named `wmain` in that module,
call that object passing the 'ARGS' (as Python strings) as positional
parameters, and use the returned object as the WSGI application
--------
child wsgidir
- exec ashd-wsgi ashd.wsgidir
+ exec ashd-wsgi3 ashd.wsgidir
match
filename *.wsgi
handler wsgidir
--------
-Since *ashd-wsgi* is a persistent handler, it can be used directly as
+Since *ashd-wsgi3* is a persistent handler, it can be used directly as
a root handler for *htparser*(1). For instance, if the directory
`/srv/www/foo` contains a `wsgi.py` file, which declares a standard
WSGI `application` object, it can be served with the following
command:
--------
-htparser plain:port=8080 -- ashd-wsgi -Ap /srv/www/foo wsgi
+htparser plain:port=8080 -- ashd-wsgi3 -Ap /srv/www/foo wsgi
--------
AUTHOR
SEE ALSO
--------
-*scgi-wsgi*(1), *ashd*(7), <http://wsgi.org/>
+*scgi-wsgi3*(1), *ashd*(7), <http://wsgi.org/>
-scgi-wsgi(1)
+scgi-wsgi3(1)
============
NAME
----
-scgi-wsgi - WSGI adapter for SCGI
+scgi-wsgi3 - WSGI adapter for SCGI
SYNOPSIS
--------
-*scgi-wsgi* [*-hA*] [*-p* 'MODPATH'] [*-T* \[HOST:]'PORT'] 'HANDLER-MODULE' ['ARGS'...]
+*scgi-wsgi3* [*-hA*] [*-p* 'MODPATH'] [*-T* \[HOST:]'PORT'] 'HANDLER-MODULE' ['ARGS'...]
DESCRIPTION
-----------
-The *scgi-wsgi* program translates SCGI requests to WSGI requests, and
-passes them to a specified Python module. It is mainly written to
+The *scgi-wsgi3* program translates SCGI requests to WSGI requests,
+and passes them to a specified Python module. It is mainly written to
emulate the behavior of *ashd-wsgi*(1), but over SCGI instead of the
native *ashd*(7) protocol, so please see its documentation for details
of Python interoperation. Unlike *ashd-wsgi* which requires CPython,
-however, *scgi-wsgi* is written in pure Python using only the standard
-library, and so should be usable by any Python implementation. If
-using it under *ashd*(7), please see the documentation for
-*callscgi*(1) as well.
+however, *scgi-wsgi3* is written in pure Python using only the
+standard library, and so should be usable by any Python
+implementation. If using it under *ashd*(7), please see the
+documentation for *callscgi*(1) as well.
-Following *callscgi*(1) conventions, *scgi-wsgi* will, by default,
+Following *callscgi*(1) conventions, *scgi-wsgi3* will, by default,
accept connections on a socket passed on its standard input (a
behavior which is, obviously, not available on all Python
implementations). Use the *-T* option to listen to a TCP address
SEE ALSO
--------
-*ashd-wsgi*(1), *callscgi*(1), <http://wsgi.org/>,
+*ashd-wsgi3*(1), *callscgi*(1), <http://wsgi.org/>,
<http://www.python.ca/scgi/>
import ashd.scgi
def usage(out):
- out.write("usage: scgi-wsgi [-hA] [-p MODPATH] [-T [HOST:]PORT] HANDLER-MODULE [ARGS...]\n")
+ out.write("usage: scgi-wsgi3 [-hA] [-p MODPATH] [-T [HOST:]PORT] HANDLER-MODULE [ARGS...]\n")
sk = None
modwsgi_compat = False
try:
handlermod = __import__(args[0], fromlist = ["dummy"])
except ImportError as exc:
- sys.stderr.write("scgi-wsgi: handler %s not found: %s\n" % (args[0], exc.args[0]))
+ sys.stderr.write("scgi-wsgi3: handler %s not found: %s\n" % (args[0], exc.args[0]))
sys.exit(1)
if not modwsgi_compat:
if not hasattr(handlermod, "wmain"):
- sys.stderr.write("scgi-wsgi: handler %s has no `wmain' function\n" % args[0])
+ sys.stderr.write("scgi-wsgi3: handler %s has no `wmain' function\n" % args[0])
sys.exit(1)
handler = handlermod.wmain(*args[1:])
else:
if not hasattr(handlermod, "application"):
- sys.stderr.write("scgi-wsgi: handler %s has no `application' object\n" % args[0])
+ sys.stderr.write("scgi-wsgi3: handler %s has no `application' object\n" % args[0])
sys.exit(1)
handler = handlermod.application