python: Changed some messages and docstrings to reflect then Python 3 changes.
authorFredrik Tolf <fredrik@dolda2000.com>
Fri, 2 Dec 2011 07:13:08 +0000 (08:13 +0100)
committerFredrik Tolf <fredrik@dolda2000.com>
Fri, 2 Dec 2011 07:13:08 +0000 (08:13 +0100)
python3/ashd-wsgi3
python3/ashd/proto.py
python3/ashd/util.py
python3/doc/ashd-wsgi3.doc [moved from python3/doc/ashd-wsgi.doc with 75% similarity]
python3/doc/scgi-wsgi3.doc [moved from python3/doc/scgi-wsgi.doc with 65% similarity]
python3/scgi-wsgi3

index 6361111..5f5b5e1 100755 (executable)
@@ -4,7 +4,7 @@ import sys, os, getopt, threading, time, locale, collections
 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
@@ -26,16 +26,16 @@ if len(args) < 1:
 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
 
index ab2152e..e695751 100644 (file)
@@ -32,10 +32,13 @@ class req(object):
     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.
     """
@@ -60,6 +63,9 @@ class req(object):
         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")
@@ -93,6 +99,9 @@ class req(object):
         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)
index 08945f2..3818e4b 100644 (file)
@@ -126,7 +126,8 @@ def respond(req, body, status = ("200 OK"), ctype = "text/html"):
     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")
similarity index 75%
rename from python3/doc/ashd-wsgi.doc
rename to python3/doc/ashd-wsgi3.doc
index 9b950b8..0af0882 100644 (file)
@@ -1,35 +1,35 @@
-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).
@@ -50,7 +50,7 @@ OPTIONS
 *-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 .`".
 
@@ -59,13 +59,13 @@ OPTIONS
        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
@@ -90,20 +90,20 @@ modules directly from the filesystem.
 
 --------
 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
@@ -112,4 +112,4 @@ Fredrik Tolf <fredrik@dolda2000.com>
 
 SEE ALSO
 --------
-*scgi-wsgi*(1), *ashd*(7), <http://wsgi.org/>
+*scgi-wsgi3*(1), *ashd*(7), <http://wsgi.org/>
similarity index 65%
rename from python3/doc/scgi-wsgi.doc
rename to python3/doc/scgi-wsgi3.doc
index 1aab621..df91477 100644 (file)
@@ -1,28 +1,28 @@
-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
@@ -59,5 +59,5 @@ Fredrik Tolf <fredrik@dolda2000.com>
 
 SEE ALSO
 --------
-*ashd-wsgi*(1), *callscgi*(1), <http://wsgi.org/>,
+*ashd-wsgi3*(1), *callscgi*(1), <http://wsgi.org/>,
 <http://www.python.ca/scgi/>
index 9befb25..4f5714e 100755 (executable)
@@ -5,7 +5,7 @@ import socket
 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
@@ -42,16 +42,16 @@ if sk is None:
 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