diff --git a/src/python/pyrte.c b/src/python/pyrte.c
index ed93d31e39c39fef39547e1cdeb143785f371541_c3JjL3B5dGhvbi9weXJ0ZS5j..f9e60dbbf97aa81e7dbc7e653e3475bfa6d05cba_c3JjL3B5dGhvbi9weXJ0ZS5j 100755
--- a/src/python/pyrte.c
+++ b/src/python/pyrte.c
@@ -170,6 +170,13 @@
   import wasd
   wasd.wsgi_run(obvious_example)
 
+PEP 333 specifies that WSGI should not buffer output and pyRTE complies but
+some tools (like Mercurial) don't buffer themselves and end up sending many
+very small records.  If buffered the throughput boost for Mercurial is about 
+x4.  This forced buffering may be enabled on a per-application basis using the
+mapping rule 'script=param=PYRTE=/WSGI=BUFFER' or by defining the logical name
+PYRTE_WSGI_FORCE_BUFFERING (in a wrapper procedure).
+
 
 REFERENCES
 ----------
@@ -235,9 +242,10 @@
 These parameters can control aspects of RTE behaviour on a per-path (and
 therefore per-script) basis using mapping rules.
 
-  script=param=PYRTE=/REUSE      reuse this Python interpreter
-  script=param=PYRTE=/NOREUSE    do not reuse this Python interpreter
-  script=param=PYRTE=/NOSTREAM   do not issue the stream-mode header
+  script=param=PYRTE=/REUSE        reuse this Python interpreter
+  script=param=PYRTE=/NOREUSE      do not reuse this Python interpreter
+  script=param=PYRTE=/NOSTREAM     do not issue the stream-mode header
+  script=param=PYRTE=/WSGI=BUFFER  force WSGI buffering mode
 
 
 LOGICAL NAMES
@@ -249,9 +257,10 @@
 PYRTE_BASIC_RTE    full interpreter cycle request processing (for comparison)
 PYRTE_CACHE_ENTRY  enables function RtePyMethRteCache()
 PYRTE_CACHE_MAX    integer size of code cache (zero to compare uncached)
-PYRTE_NOREUSE_INTERPRETER  do not reuse interpreter for each script instance
-PYRTE_USAGE_LIMIT  integer number of requests before voluntary exit
-
+PYRTE_NOREUSE_INTERPRETER   do not reuse interpreter for each script instance
+PYRTE_USAGE_LIMIT   integer number of requests before voluntary exit
+PYRTE_WSGI_FORCE_BUFFERING  enable buffering with WASD, this break the WSGI
+                            specification but may give a performance boost.
 
 BUILD DETAILS
 -------------
@@ -262,9 +271,12 @@
 
 VERSION HISTORY (update SOFTWAREVN as well!)
 ---------------
+19-APR-2008  JFP  v1.1.2, WSGI buffered output (see description above)
+17-JAN-2008  MGD  v1.1.1, CgiVar() and CgiVarDclSymbol() ensure an empty
+                            SCRIPT_NAME *is* empty (not the WASD-ism "/")
 05-JAN-2008  MGD  v1.1.0, WSGI support
 22-APR-2007  MGD  v1.0.0, initial development
 */
 /*****************************************************************************/
 
 #define SOFTWARECR "Copyright (C) 2007,2008 Mark G.Daniel"
@@ -265,10 +277,10 @@
 05-JAN-2008  MGD  v1.1.0, WSGI support
 22-APR-2007  MGD  v1.0.0, initial development
 */
 /*****************************************************************************/
 
 #define SOFTWARECR "Copyright (C) 2007,2008 Mark G.Daniel"
-#define SOFTWAREVN "1.1.0"
+#define SOFTWAREVN "1.1.2"
 #define SOFTWARENM "PYRTE"
 #ifdef __ALPHA
 #  define SOFTWAREID SOFTWARENM " AXP-" SOFTWAREVN
@@ -357,7 +369,8 @@
      UsageLimit,
      WasdHeadersSent,
      WsgiHeadersSent,
-     WsgiRunApp;
+     WsgiRunApp,
+     WsgiForceBuffering;
 
 unsigned long  ExitStatus;
 
@@ -570,6 +583,7 @@
 int ByteCodeUpToDate (struct CodeCacheStruct*);
 char* CgiVar (char*);
 char* CgiVarDclSymbol (char*);
+int EmptyScriptName (char*, char*);
 void EnsureExit (unsigned long*);
 int lib$stop (__unknown_params);
 void LoadByteCode (char*, char*, struct CodeCacheStruct*);
@@ -623,6 +637,9 @@
             fflush (stdout);
          }
 
+   WsgiForceBuffering = 
+         (TrnLnm ("PYRTE_WSGI_FORCE_BUFFERING", NULL) != NULL);
+
    /* if it doesn't look like CGI environment then forget it */
    if (!TrnLnm ("HTTP$INPUT", NULL)) exit (SS$_ABORT);
 
@@ -1511,7 +1528,7 @@
 
       fwrite (DataPtr, DataLength, 1, stdout);
       /* WSGI always writes data unbuffered */
-      if (WsgiRunApp) fflush (stdout);
+      if (WsgiRunApp && !WsgiForceBuffering) fflush (stdout);
 
       Py_INCREF (Py_None);
       return (Py_None);
@@ -2187,7 +2204,7 @@
                /** if (Debug) fprintf (stdout, "pIter()\n"); **/
                AppOutputCount += DataLength;
                fwrite (DataPtr, DataLength, 1, stdout);
-               fflush (stdout);
+               if (!WsgiForceBuffering) fflush (stdout);
             }
       Py_DECREF (pItem);
    }
@@ -2463,6 +2480,9 @@
    {
       while (*cptr && *cptr != '/') cptr++;
       if (!*cptr) break;
-      if (!strncmp (cptr, "/reuse", 6) || !strncmp (cptr, "/REUSE", 6)) 
+      if (!strncasecmp (cptr, "/wsgi=buffer", 12))
+         WsgiForceBuffering = 1;
+      else
+      if (!strncasecmp (cptr, "/reuse", 6)) 
          ReuseInterpreter = 1;
       else
@@ -2467,5 +2487,5 @@
          ReuseInterpreter = 1;
       else
-      if (!strncmp (cptr, "/noreuse", 8) || !strncmp (cptr, "/NOREUSE", 8)) 
+      if (!strncasecmp (cptr, "/noreuse", 8)) 
          ReuseInterpreter = 0;
       else
@@ -2470,5 +2490,5 @@
          ReuseInterpreter = 0;
       else
-      if (!strncmp (cptr, "/nostream", 9) || !strncmp (cptr, "/NOSTREAM", 9)) 
+      if (!strncasecmp (cptr, "/nostream", 9)) 
          NoStreamMode = 1;
       else
@@ -2473,6 +2493,6 @@
          NoStreamMode = 1;
       else
-      if (!strncmp (cptr, "/dbug", 5) || !strncmp (cptr, "/DBUG", 5)) 
+      if (!strncasecmp (cptr, "/dbug", 5)) 
          Debug = 1;
       cptr++;
    }
@@ -2630,7 +2650,8 @@
 
    static int  CalloutDone,
                StructLength;
-   static char  *NextVarNamePtr;
+   static char  *EmptyScriptNamePtr = NULL,
+                *NextVarNamePtr;
    static char  StructBuffer [CGIVAR_STRUCT_SIZE];
    static FILE  *CgiPlusIn;
    
@@ -2672,7 +2693,15 @@
             sptr = (NextVarNamePtr += SOUS);
             NextVarNamePtr += Length;
             /* by default CGI variable names are prefixed by "WWW_", ignore */
-            return (sptr + 4);
+            sptr += 4;
+            /* ensure an empty SCRIPT_NAME *is* empty */
+            if (toupper(*sptr) != 'S') return (sptr);
+            if (toupper(*(sptr+1)) != 'C') return (sptr); 
+            if (!EmptyScriptName (sptr, NULL)) return (sptr);
+            if (EmptyScriptNamePtr) return (EmptyScriptNamePtr);
+            EmptyScriptNamePtr = calloc (1, 13);
+            if (EmptyScriptNamePtr) strcpy (EmptyScriptNamePtr, "SCRIPT_NAME=");
+            return (EmptyScriptNamePtr);
          }
 
          /* standard CGI */
@@ -2692,7 +2721,16 @@
             for (cptr = VarName; *cptr && *sptr && *sptr != '='; cptr++, sptr++)
                if (toupper(*cptr) != toupper(*sptr)) break;
             /* if found return a pointer to the value */
-            if (!*cptr && *sptr == '=') return (sptr + 1);
+            if (!*cptr && *sptr == '=')
+            {
+               sptr++;
+               /* ensure an empty SCRIPT_NAME *is* empty */
+               if (toupper(*sptr) != 'S') return (sptr);
+               if (toupper(*(sptr+1)) != 'C') return (sptr); 
+               if (!EmptyScriptName (VarName, sptr)) return (sptr);
+               while (*sptr) sptr++;
+               return (sptr);
+            }
          }
          /* not found */
          return (NULL);
@@ -2888,8 +2926,8 @@
       strncpy (WwwName+4, cptr, sizeof(WwwName)-5);
       NameDsc.dsc$w_length = strlen(WwwName);
       ValueDsc.dsc$a_pointer = Value;
-      ValueDsc.dsc$w_length = 1023;
+      ValueDsc.dsc$w_length = sizeof(Value)-1;
    
       status = lib$get_symbol (&NameDsc, &ValueDsc, &ShortLength, NULL);
       if (status & 1)
       {
@@ -2892,8 +2930,11 @@
    
       status = lib$get_symbol (&NameDsc, &ValueDsc, &ShortLength, NULL);
       if (status & 1)
       {
-         cptr = malloc (ShortLength+1);
+         /* ensure an empty SCRIPT_NAME *is* empty */
+         if (toupper(VarName[0]) != 'S' && EmptyScriptName (VarName, Value))
+            ShortLength = 0;
+         cptr = calloc (1, ShortLength+1);
          memcpy (cptr, Value, ShortLength);
          cptr[ShortLength] = '\0';
          return (cptr);
@@ -2910,6 +2951,44 @@
 
 /*****************************************************************************/
 /*
+Suppress the WASD-ism of an empty or 'root' script name (i.e. "/").
+If 'VarValue' is none then 'VarName' is "NAME=<value>" string.
+*/
+
+int EmptyScriptName
+(
+char *VarName,
+char *VarValue
+)
+{
+   char  *cptr = "SCRIPT_NAME",
+         *sptr = VarName;
+
+   /*********/
+   /* begin */
+   /*********/
+
+   if (Debug) fprintf (stdout, "EmptyScriptName() %s %s\n", VarName, VarValue);
+
+   while (*cptr && *sptr && *sptr != '=')
+   { 
+      if (*cptr != toupper(*sptr)) break;
+      cptr++;
+      sptr++;
+   }
+   if (*cptr || (*sptr && *sptr != '=')) return (0);
+   if (VarValue)
+   {
+      if (*(unsigned short*)VarValue != '/\0') return (0);
+      if (!*VarValue) return (0);
+      return (1);
+   }
+   if (*(unsigned short*)(sptr+1) != '/\0') return (0);
+   return (1);
+}
+
+/*****************************************************************************/
+/*
 If false then initialize the LIB$ stats timer.
 If true return a pointer to a static buffer containings a stats string.
 */
diff --git a/src/python/readmore.html b/src/python/readmore.html
index ed93d31e39c39fef39547e1cdeb143785f371541_c3JjL3B5dGhvbi9yZWFkbW9yZS5odG1s..f9e60dbbf97aa81e7dbc7e653e3475bfa6d05cba_c3JjL3B5dGhvbi9yZWFkbW9yZS5odG1s 100755
--- a/src/python/readmore.html
+++ b/src/python/readmore.html
@@ -1,45 +1,95 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
-  <title>Python RTE for WASD</title>
-  <meta content="Mark Daniel" name="author">
-  <meta content="PyRTE installation and configuration"
- name="description">
-  <meta content="Mozilla Edit sucks big-time!" name="comment">
-</head>
-<body style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"
- link="#0000cc" vlink="#000099">
-<thumb sborient="vertical" orient="vertical" flex="1" pack="center"
- align="center" inherits="orient,sborient=orient"
- sbattr="scrollbar-thumb"></thumb>
-<h2
- style="text-decoration: underline; font-family: helvetica,arial,sans-serif;">Python
-Run-Time Environment
-<br></h2>
-<span style="font-family: helvetica,arial,sans-serif;"></span><span
- style="font-weight: bold; text-decoration: underline; font-family: helvetica,arial,sans-serif;">PyRTE
-v1.1.0, 10 Jan 2008</span>
-<ul style="font-family: helvetica,arial,sans-serif;">
-  <li><a href="#Installation">Installation</a> </li>
-  <li><a href="#Configure_WASD">Configure WASD</a> </li>
-  <li><a href="#Example_Scripts">Example Scripts</a></li>
-  <li><a href="#WSGI_Interface">Web Server Gateway Interface</a><span
- style="text-decoration: underline;"></span></li>
-  <li><span style="text-decoration: underline;"></span><a
- href="#Example_WSGI_Scripts">Example WSGI Scripts</a></li>
-  <li><a href="#Leveraging_PyRTE">Leveraging PyRTE</a></li>
-  <li><a href="#Problems">Problems?</a></li>
-  <li><a href="#Acknowlegements">Acknowlegements</a> </li>
-</ul>
-<hr style="font-family: helvetica,arial,sans-serif;" align="left"
- noshade="noshade" size="1" width="65%">
-<p style="font-family: helvetica,arial,sans-serif;">PyRTE is an
-interface to a <a href="http://www.python.org/">Python</a> interpreter
-engine and environment for the WASD VMS Web server.&nbsp; It is designed to be
-able to be used in standard CGI and CGIplus/RTE persistent scripting
-modes.&nbsp; The persistent modes (default) provide a ~35x (yes, an approximate
+<HTML>
+<HEAD>
+<TITLE>Python Run-Time Environment</TITLE>
+
+<STYLE TYPE="text/css">
+body { font-family:arial,helvetica; }
+
+h1 {
+  font-size:150%; font-weight:bold; text-decoration:underline;
+}
+
+h2 {
+  font-size:130%; font-weight:bold; text-decoration:underline;
+  letter-spacing:1px;
+  padding-top:1.2em;
+}
+
+h3 {
+  font-size:120%; font-weight:bold;
+  padding-top:0.8em;
+}
+
+hr { color:#888888; background-color:#888888; height:1px; border:0; }
+
+.code {
+  border-style:solid; border-color:#888888; border-left-width:1;
+  border-top-width:0; border-right-width:0; border-bottom-width:0;
+  background-color:#eeeeee;
+  margin-left:2em;
+  margin-right:5em;
+  padding:0.3em;
+  padding-left:1em;
+}
+
+.quote {
+  border-style:dotted; border-color:#888888; border-width:1;
+  font-size:90%;
+  background-color:#eeeeee;
+  margin-left:2em;
+  margin-right:5em;
+  padding:0.3em;
+  padding-left:1em;
+}
+
+.refer {
+  font-size:90%; width:90%; text-align:right;
+}
+
+.which table, .which th, .which td {
+  border-style:solid;
+  border-width:1px;
+  border-color:#888888; 
+  border-collapse:collapse;
+}
+</STYLE>
+
+</HEAD>
+<BODY BGCOLOR="#ffffff" TEXT="#000000" LINK="#0000cc" VLINK="#0000cc">
+
+<CENTER>
+
+<H1>Python Run-Time Environment</H1>
+<H3>Version 1.1.2, 19th April 2008</H3>
+
+<P><B>Copyright &copy; 2007,2008 Mark G. Daniel</B>
+<BR>This program, comes with ABSOLUTELY NO WARRANTY.
+<BR>This is free software, and you are welcome to redistribute it under the
+<BR>conditions of the GNU GENERAL PUBLIC LICENSE, version 3, or any later version.
+<BR><A HREF="http://www.gnu.org/licenses/gpl.txt">http://www.gnu.org/licenses/gpl.txt</A>
+
+</CENTER>
+
+<H2 STYLE="margin-left:1.5em;">Contents</H2>
+
+<UL>
+<LI><A HREF="#install">Installation</A>
+<LI><A HREF="#config">Configure WASD</A>
+<LI><A HREF="#example">Example Scripts</A>
+<LI><A HREF="#wsgi">Web Server Gateway Interface</A>
+<LI><A HREF="#lever">Leveraging PyRTE</A>
+<LI><A HREF="#problems">Problems</A>
+<LI><A HREF="#ackn">Acknowlegements</A>
+</UL>
+
+<BR><HR ALIGN=left SIZE=1 NOSHADE><BR>
+
+<P> PyRTE is an interface to a <A HREF="http://www.python.org/">Python</A>
+interpreter engine and environment for the WASD VMS Web server.  It is designed
+to be able to be used in standard CGI and CGIplus/RTE persistent scripting
+modes.  The persistent modes (default) provide a ~35x (yes, an approximate
 thirty-five times) improvement in script activation times (compared to
 CGI/command-line) and comparably reduced load on both server and system. Note
 that this package does not contain the Python interpreter or kit, that has to
 be obtained and installed separately (a simple matter as it is provided via a
 PCSI package).
@@ -41,207 +91,215 @@
 thirty-five times) improvement in script activation times (compared to
 CGI/command-line) and comparably reduced load on both server and system. Note
 that this package does not contain the Python interpreter or kit, that has to
 be obtained and installed separately (a simple matter as it is provided via a
 PCSI package).
-</p>
-<p style="font-family: helvetica,arial,sans-serif;"> PyRTE is linked
-against the Python interpreter
-shareable image and so shares a set of Python capabilities in common
-with
-command-line OpenVMS Python.&nbsp; Alpha (AXP) and Itanium object
-modules are provided for the VMS platforms available for Python.<br>
-</p>
-<span style="text-decoration: underline;"></span>PyRTE has been
-developed and tested on VMS V8.3 using the WASD v9.2.0 and VMS Python
-kit&nbsp; <span style="font-family: monospace;">JFP AXPVMS PYTHON251</span>&nbsp;
-available from and documented at 
-<a href="http://vmspython.dyndns.org">http://vmspython.dyndns.org</a>/.&nbsp;
-JFP's Python kits are kept very up-to-date as Python updates or
-implementation problems arise.<br>
-<br>
-<span style="font-weight: bold;"></span>
-<h3
- style="text-decoration: underline; font-family: helvetica,arial,sans-serif;">Installation</h3>
-<ol style="font-family: helvetica,arial,sans-serif;">
-  <li>If Python for OpenVMS is not currently installed, or if the
-version is not up-to-date, obtain the latest kit from<br>
-    <div style="margin-left: 40px;">
-    <pre><a href="http://vmspython.dyndns.org">http://vmspython.dyndns.org</a>/</pre>
-    </div>
-and install according
-to the instructions available.<br>
-    <br>
-  </li>
-  <li>When updating it is suggested that any exisiting PyRTE kit be
-renamed out of the way before installing this kit.&nbsp; After
-successful
-installation and testing the old kit may be deleted. <br>
-    <pre style="margin-left: 40px;">$ RENAME HT_ROOT:[SRC]PYTHON.DIR HT_ROOT:[SRC]PYTHON_nnn.DIR<br></pre>
-  </li>
-  <li>
-    <p> Obtain the PyRTE kit from (or one of the mirror sites) </p>
-    <pre style="margin-left: 40px;"><a
- href="http://wasd.vsm.com.au/wasd/">http://wasd.vsm.com.au/wasd/</a></pre>
-  </li>
-  <li>UNZIP the kit<br>
-    <pre style="margin-left: 40px;">$ SET DEFAULT HT_ROOT:[000000]<br>$ UNZIP "-V" location:PYRTEnnn.ZIP</pre>
-  </li>
-  <li>Note that this performs a link-only build against the supplied
-object modules.&nbsp; Compilation is also available.<br>
-    <pre style="margin-left: 40px;">$ SET DEFAULT HT_ROOT:[SRC.PYTHON]<span
- style="font-family: helvetica,arial,sans-serif;"></span><br><span
- style="font-family: helvetica,arial,sans-serif;"></span>$ @BUILD_PYRTE LINK<br></pre>
-  </li>
-  <li>Copy the PyRTE engine to the script executable location.<br>
-    <pre style="margin-left: 40px;">$ COPY HT_EXE:PYRTE.EXE CGI_EXE:</pre>
-  </li>
-  <li><a href="#configure_wasd">Configure</a> the Web server<br>
-    <br>
-  </li>
-  <li>S<span style="font-family: helvetica,arial,sans-serif;"></span>tart
-scripting &nbsp;:^)<br>
-Try the <a href="#Example_Scripts">example scripts</a>.<br>
-    <br>
-  </li>
-</ol>
-<ol style="font-family: helvetica,arial,sans-serif;">
-</ol>
-<h3
- style="text-decoration: underline; font-family: helvetica,arial,sans-serif;"><a
- name="Configure_WASD"></a>Configure
-WASD </h3>
-Although there are experimentation modes built into PyRTE basically it
-will be used as a WASD Run-Time Environment providing persisten Python
-interpreter(s) and environment(s) for Python scripts and
-applications.&nbsp; Benchmarking indicates the CGIplus/RTE use reduces
-activation time to 3% of CGI (yes, that's correct, by a factor 35 - a
-python interpreter is quite expensive to instantiate).&nbsp; There are
-subtle
-differences in the way CGIplus and RTE parse and provide the PATH_INFO
-data (see the "WASD Scripting Overview" for detail).<span
- style="font-family: helvetica,arial,sans-serif;"></span><br>
-<span style="font-family: helvetica,arial,sans-serif;"></span>
-<h4>Configuration and Mapping</h4>
-One or more of the following approaches can be implemented.&nbsp;
-Remember to<br>
-<pre style="margin-left: 40px;">$ HTTPD /DO=MAP</pre>
-after changing mapping rules.<br>
-<ul>
-  <li>Server global
-configuration (HTTPD$CONFIG) can be used to indicate
-which file types should activate the Python engine and how perform
-non-script access. </li>
-</ul>
-<pre style="font-family: helvetica,arial,sans-serif; margin-left: 80px;"><span
- style="font-family: monospace;"># HTTPD$CONFIG</span><br
- style="font-family: monospace;"><span style="font-family: monospace;">[DclScriptRunTime]</span><br
- style="font-family: monospace;"><span style="font-family: monospace;">.PY $CGI-BIN:[000000]PYRTE<br
- style="font-family: monospace;"></span><span
- style="font-family: monospace;">[AddType]</span><span
- style="font-family: monospace;"></span><br
- style="font-family: monospace;"><span style="font-family: monospace;">.PY   text/plain  Python source</span><br
- style="font-family: monospace;"><span style="font-family: monospace;"></span><span
- style="font-family: monospace;">.PYC  application/octet-stream  Python byte-code<br>.PYO  application/octet-stream  Python optimised byte-code<br></span></pre>
-<ul>
-  <li>The following rules require the Python script files to be located
-in
-the site
-administrator controlled /cgi-bin/ path.<span
- style="font-family: monospace;"><br>
-    </span>
-    <pre style="margin-left: 40px;"># HTTPD$MAP<br>exec /py-bin/* (cgi_exe:pyrte)/cgi-bin/* \<br>     script=syntax=unix script=query=none map=once ods=5</pre>
-  </li>
-  <li>Alternatively, to
-automatically map scripts ending in <span
- style="font-family: monospace;">.py</span> to the RTE
-engine. </li>
-</ul>
-<pre style="font-family: helvetica,arial,sans-serif; margin-left: 80px;"><span
- style="font-family: monospace;"># HTTPD$MAP for automatic RTE usage</span><br
- style="font-family: monospace;"><span style="font-family: monospace;">map /cgi-bin/*.py* /py-bin/*.py*</span><span
- style="font-family: monospace;"><br>exec /py-bin/* </span>(cgi_exe:pyrte)/cgi-bin/* \<br>       script=syntax=unix script=query=none map=once ods=5<span
- style="font-family: monospace;"></span><span
- style="font-family: monospace;"></span></pre>
-<ul>
-  <li>The following
-rule would allow <span style="font-family: monospace;">.py</span>
-type
-files anywhere in the mapped
-directory
-structure to be executed. This may be what is desired but might be
-dangerous in some circumstances.<span style="font-family: monospace;"></span><br>
-    <pre style="margin-left: 40px;"># HTTPD$MAP<span
- style="font-family: monospace;"><br>exec /web/**.py* /web/*.py*</span> \<br>     script=syntax=unix script=query=none map=once ods=5<span
- style="font-family: monospace;"></span></pre>
-  </li>
-  <li>It is a general principal that Web applications requiring write
-access to parts of the file-system
-be run in a unique account with those file-system areas being owned by
-and having protections associated with that account.&nbsp; WASD
-provides this using its PERSONA facility (see the "WASD
-Scripting Overview" for detail).<br>
-    <pre style="margin-left: 40px;"># HTTPD$MAP<span
- style="font-family: monospace;"><br>exec /appx/**.py* /appx_root/*.py*</span> \<br>     script=syntax=unix script=query=none map=once ods=5 \<br>     script=as=USERX<span
- style="font-family: sans-serif;"></span></pre>
-  </li>
-  <li><span style="font-family: sans-serif;">To provide in-situ
-activation of the example scripts below use the following configuration.<br>
-    </span>
-    <pre style="margin-left: 40px;"># HTTPD$MAP<br>exec /py-bin/* (cgi_exe:pyrte)/ht_root/src/python/scripts/* \<br>     script=syntax=unix script=query=none map=once ods=5<span
- style="font-family: sans-serif;"></span></pre>
-  </li>
-</ul>
-<div style="margin-left: 40px;">Note that the location of the above
-example scripts haS changed to <span style="font-family: monospace;">[.SCRIPTS]</span>
-since the v1.0 release.<br>
-<br>
-</div>
-<p style="font-family: helvetica,arial,sans-serif;"> </p>
-<h3
- style="text-decoration: underline; font-family: helvetica,arial,sans-serif;"><a
- name="Example_Scripts"></a>Example
-Scripts</h3>
-<p style="font-family: helvetica,arial,sans-serif;">
-</p>
-<p style="font-family: helvetica,arial,sans-serif;"> After
-configuration (as described immediately above) the following scripts
-may be used to confirm
-the
-environment is functioning.
-</p>
-<ul style="font-family: helvetica,arial,sans-serif;">
-  <li> <a href="/py-bin/pyrte_test1.py">/py-bin/pyrte_test1.py</a>&nbsp;
-    <br>
-  </li>
-  <li> <a href="/py-bin/pyrte_test2.py">/py-bin/pyrte_test2.py</a> </li>
-  <li> <a href="/py-bin/pyrte_test3.py">/py-bin/pyrte_test3.py</a> </li>
-  <li> <a href="/py-bin/pyrte_test4.py">/py-bin/pyrte_test4.py</a> </li>
-  <li> <a href="/py-bin/pyrte_chart_pie.py">/py-bin/pyrte_chart_pie.py</a></li>
-</ul>
-Some of these examples also support CGIplus mode for comparison
-purposes.<br>
-<br>
-Of course the Python code in the script may be inspected from the
-source
-directory:<br>
-<br>
-<div style="margin-left: 40px;"><a href="/ht_root/src/python/scripts/">/ht_root/src/python/scripts/</a><br>
-</div>
-<br>
-<h3
- style="text-decoration: underline; font-family: helvetica,arial,sans-serif;"><a
- name="WSGI_Interface"></a>Web Server Gateway Interface</h3>
-PyRTE contains a Web Server Gateway Interface v1.0 (WSGI).&nbsp;
-This is a Python standard specification for web servers and application
-servers to communicate with web applications (though it can also be
-used for more than that).<br>
-<br>
-<div style="margin-left: 40px;"><a href="http://www.wsgi.org/wsgi/">http://www.wsgi.org/wsgi/</a>&nbsp;<br>
-<a href="http://www.python.org/dev/peps/pep-0333/">http://www.python.org/dev/peps/pep-0333/</a><br>
-</div>
-<p> The WSGI code has been developed under the sponsorship of <b>SysGroup</b>
-<blockquote> 
-<a href="http://www.sysgroup.fr/">http://www.sysgroup.fr/</a>
-</blockquote> 
+
+<P> PyRTE is linked against the Python interpreter shareable image and so
+shares a set of Python capabilities in common with command-line OpenVMS Python. 
+Alpha (AXP) and Itanium object modules are provided for the VMS platforms
+available for Python.
+
+<P> PyRTE has been developed and tested on VMS V8.3 using the WASD v9.2.0 and
+VMS Python kit  JFP AXPVMS PYTHON251  available from and documented at <A
+HREF="http://vmspython.dyndns.org/">http://vmspython.dyndns.org/</A>.  JFP's
+Python kits are kept very up-to-date as Python updates or implementation
+problems arise.
+
+<A NAME="install">
+<H2>Installation</H2>
+</A>
+
+<UL>
+
+<LI> If Python for OpenVMS is not currently installed, or if the version is not
+up-to-date, obtain the latest kit from
+
+<BLOCKQUOTE>
+<A HREF="http://vmspython.dyndns.org/">http://vmspython.dyndns.org/</A>
+</BLOCKQUOTE>
+
+and install according to the instructions available.
+
+<P><LI> When updating it is suggested that any exisiting PyRTE kit be renamed
+out of the way before installing this kit.  After successful installation and
+testing the old kit may be deleted.
+
+<PRE CLASS="code">
+$ RENAME HT_ROOT:[SRC]PYTHON.DIR HT_ROOT:[SRC]PYTHON_nnn.DIR
+</PRE>
+
+<LI> Obtain the PyRTE kit from (or one of the mirror sites)
+
+<BLOCKQUOTE>
+<A HREF="http://wasd.vsm.com.au/wasd/">http://wasd.vsm.com.au/wasd/</A>
+</BLOCKQUOTE>
+
+<LI> UNZIP the kit
+
+<PRE CLASS="code">
+$ SET DEFAULT HT_ROOT:[000000]
+$ UNZIP "-V" location:PYRTEnnn.ZIP
+</PRE>
+
+<LI> Note that this performs a link-only build against the supplied object
+modules.  Compilation is also available.
+
+<PRE CLASS="code">
+$ SET DEFAULT HT_ROOT:[SRC.PYTHON]
+$ @BUILD_PYRTE LINK
+</PRE>
+
+<LI> Copy the PyRTE engine to the script executable location.
+
+<PRE CLASS="code">
+$ COPY HT_EXE:PYRTE.EXE CGI_EXE:
+</PRE>
+
+<LI> <A HREF="#configure_wasd">Configure</A> the Web server.
+
+<P><LI> Start scripting&nbsp; <TT>:^)</TT>
+<BR>Try the <A HREF="#example">example scripts</a>.
+
+</UL>
+
+<A NAME="config">
+<H2>Configure WASD</H2>
+</A>
+
+<P> Although there are experimentation modes built into PyRTE basically it will be
+used as a WASD Run-Time Environment providing persisten Python interpreter(s)
+and environment(s) for Python scripts and applications.  Benchmarking indicates
+the CGIplus/RTE use reduces activation time to 3% of CGI (yes, that's correct,
+by a factor 35 - a python interpreter is quite expensive to instantiate). 
+There are subtle differences in the way CGIplus and RTE parse and provide the
+PATH_INFO data (see the "WASD Scripting Overview" for detail).
+
+<H3>Configuration and Mapping</H3>
+
+One or more of the following approaches can be implemented.
+
+<UL>
+
+<LI> Server global configuration (HTTPD$CONFIG) can be used to indicate which
+file types should activate the Python engine and how perform non-script access.
+
+<PRE CLASS="code">
+# HTTPD$CONFIG
+[DclScriptRunTime]
+.PY $CGI-BIN:[000000]PYRTE
+[AddType]
+.PY   text/plain  Python source
+.PYC  application/octet-stream  Python byte-code
+.PYO  application/octet-stream  Python optimised byte-code
+</PRE>
+
+<LI> The following rules require the Python script files to be located in the
+site administrator controlled /cgi-bin/ path.
+
+<PRE CLASS="code">
+# HTTPD$MAP
+exec /py-bin/* (cgi_exe:pyrte)/cgi-bin/* \
+     script=syntax=unix script=query=none map=once ods=5
+</PRE>
+
+<LI> Alternatively, to automatically map scripts ending in .py to the RTE
+engine. 
+
+<PRE CLASS="code">
+# HTTPD$MAP for automatic RTE usage
+map /cgi-bin/*.py* /py-bin/*.py*
+exec /py-bin/* (cgi_exe:pyrte)/cgi-bin/* \
+       script=syntax=unix script=query=none map=once ods=5
+</PRE>
+
+<LI> The following rule would allow .py type files anywhere in the mapped
+directory structure to be executed. This may be what is desired but might be
+dangerous in some circumstances.
+
+<PRE CLASS="code">
+# HTTPD$MAP
+exec /web/**.py* /web/*.py* \
+     script=syntax=unix script=query=none map=once ods=5
+</PRE>
+
+<LI> It is a general principal that Web applications requiring write access to
+parts of the file-system be run in a unique account with those file-system
+areas being owned by and having protections associated with that account.  WASD
+provides this using its PERSONA facility (see the "WASD Scripting Overview" for
+detail).
+
+<PRE CLASS="code">
+# HTTPD$MAP
+exec /appx/**.py* /appx_root/*.py* \
+     script=syntax=unix script=query=none map=once ods=5 \
+     script=as=USERX
+</PRE>
+
+<LI> To provide in-situ activation of the example scripts below use the
+following configuration.
+
+<PRE CLASS="code">
+# HTTPD$MAP
+exec /py-bin/* (cgi_exe:pyrte)/ht_root/src/python/scripts/* \
+     script=syntax=unix script=query=none map=once ods=5
+</PRE>
+
+Note that the location of the above example scripts has changed to [.SCRIPTS]
+since the v1.0 release.
+
+</UL>
+
+<P> Remember to
+
+<PRE CLASS="code">
+$ HTTPD /DO=MAP
+</PRE>
+
+after changing mapping rules.
+
+<A NAME="example">
+<H2>Example Scripts</H2>
+</A>
+
+<P> After configuration (as described immediately above) the following scripts
+may be used to confirm the environment is functioning.
+
+<UL>
+<LI> <A HREF="/py-bin/pyrte_test1.py">/py-bin/pyrte_test1.py</A> 
+<LI> <A HREF="/py-bin/pyrte_test2.py">/py-bin/pyrte_test2.py</A>
+<LI> <A HREF="/py-bin/pyrte_test3.py">/py-bin/pyrte_test3.py</A>
+<LI> <A HREF="/py-bin/pyrte_test4.py">/py-bin/pyrte_test4.py</A>
+<LI> <A HREF="/py-bin/pyrte_chart_pie.py">/py-bin/pyrte_chart_pie.py</A>
+</UL>
+
+<P> Some of these examples also support CGIplus mode for comparison purposes.
+
+<P> Of course the Python code in the script may be inspected from the source
+directory:
+
+<BLOCKQUOTE>
+<A HREF="/ht_root/src/python/scripts/">/ht_root/src/python/scripts/</A>
+</BLOCKQUOTE>
+
+<A NAME="wsgi">
+<H2>Web Server Gateway Interface</H2>
+</A>
+
+<P> PyRTE contains a Web Server Gateway Interface v1.0 (WSGI).  This is a
+Python standard specification for web servers and application servers to
+communicate with web applications (though it can also be used for more than
+that).
+
+<UL>
+<LI><A HREF="http://www.wsgi.org/wsgi/">http://www.wsgi.org/wsgi/</A> 
+<LI><A HREF="http://www.python.org/dev/peps/pep-0333/">http://www.python.org/dev/peps/pep-0333/</A>
+</UL>
+
+<P> The WSGI code has been developed under the sponsorship of SysGroup
+
+<BLOCKQUOTE>
+<A HREF="http://www.sysgroup.fr/">http://www.sysgroup.fr/</A> 
+</BLOCKQUOTE>
+
 and generously made available to the wider WASD community.
 
@@ -246,10 +304,10 @@
 and generously made available to the wider WASD community.
 
-<p>
-The following is an example of a simple (and classic) WSGI application
-being activated using the PyRTE <span style="font-family: monospace;">wasd.wsgi_run()</span>
-function.<br>
-<pre style="margin-left: 40px;">def hello_world (environ, start_response):
+<P> The following is an example of a simple (and classic) WSGI application
+being activated using the PyRTE <TT>wasd.wsgi_run()</TT> function.
+
+<PRE CLASS="code">
+def hello_world (environ, start_response):
     status = '200 OK'
     response_headers = [('Content-type','text/plain')]   
     start_response(status, response_headers)
@@ -257,142 +315,143 @@
 
 import wasd
 wasd.wsgi_run(hello_world)
-</pre> 
-<h3
- style="text-decoration: underline; font-family: helvetica,arial,sans-serif;"><a
- name="Example_WSGI_Scripts"></a>Example
-WSGI Scripts</h3>
-<p style="font-family: helvetica,arial,sans-serif;">
-</p>
-<p style="font-family: helvetica,arial,sans-serif;"> The following
-scripts may be used to confirm
-the
-environment is functioning.
-</p>
-<ul style="font-family: helvetica,arial,sans-serif;">
-  <li> <a href="/py-bin/wsgi_test1.py">/py-bin/wsgi_test1.py</a>&nbsp;
-    <br>
-  </li>
-  <li> <a href="/py-bin/wsgi_test2.py">/py-bin/wsgi_test2.py</a>
-  </li>
-  <li> <a href="/py-bin/wsgi_test3.py">/py-bin/wsgi_test3.py</a>
-  </li>
-  <li> <a href="/py-bin/wsgi_test4.py">/py-bin/wsgi_test4.py</a></li>
-</ul>
-The Python code in the script may be inspected from the source
-directory:<br>
-<br>
-<div style="margin-left: 40px;"><a
- href="../../../../ht_root/src/python/scripts/">/ht_root/src/python/scripts/</a><br>
-</div>
-<br>
-There are also equivalent 'wsgiref' scripts available for
-comparison.&nbsp; Just add 'ref' to the 'wsgi' in the script name.<br>
-<br>
-<div style="margin-left: 40px;"></div>
-<div style="margin-left: 40px;"><thumb sborient="vertical"
- orient="vertical" flex="1" pack="center" align="center"
- inherits="orient,sborient=orient" sbattr="scrollbar-thumb"></thumb></div>
-<h3
- style="text-decoration: underline; font-family: helvetica,arial,sans-serif;"><a
- name="Leveraging_PyRTE"></a>Leveraging PyRTE</h3>
-Python scripts activated using the default persistent engine generally
-have low-latency, low-system-impact characteristics and seem to perform
-reliably and efficiently.&nbsp; The PyRTE generally handles all the
-WASD server interaction requirements.&nbsp; However there may be
-occasions where the application itself benefits from being persistent
-(many Python Web application are written with this in mind) or where
-more control needs to be exercised by the application designer.&nbsp;
-The WASD PyRTE provides a WASD Python module that provides an API for
-some of these aspects.&nbsp; Rather than clutter this document with
-such arcane detail the description may be found in the prologue to the
-PyRTE source code:<br>
-<br>
-<div style="margin-left: 40px;"><a href="/ht_root/src/python/pyrte.c">/ht_root/src/python/pyrte.c</a><br>
-</div>
-<br>
-An example of where an application benefits from an explicitly CGIplus
-activation is MoinMoin:<br>
-<br>
-<div style="margin-left: 40px;"><a
- href="http://moinmoin.wikiwikiweb.de/">http://moinmoin.wikiwikiweb.de/</a><br>
-<a href="http://vmspython.dyndns.org/MoinMoin">http://vmspython.dyndns.org/MoinMoin</a><br>
-<a href="http://vmspython.dyndns.org/DownloadAndInstallationMoinMoin">http://vmspython.dyndns.org/DownloadAndInstallationMoinMoin</a><br>
-</div>
-<br>
-MoinMoin is generally run independently to a system's primary Web
-server
-using the embedded Web server available for Python.&nbsp; Reverse proxy
-is often then use to provide and control access through to the
-persistent
-MoinMoin server.<br>
-<br>
-Using the same principle of keeping MoinMoin persistent (for the
-obvious latency and efficiency benefits) it can be run and controlled
-directly by the WASD Web server using a CGIplus <span
- style="font-style: italic;">wrapper</span> DCL procedure and a little
-Python <span style="font-style: italic;">glue</span> (directly derived
-from persistence code already present in the MoinMoin package). <br>
-<br>
-<div style="margin-left: 40px;"><a
- href="/ht_root/src/python/moincgiplus.com">/ht_root/src/python/moincgiplus.com</a></div>
-<br>
-The same principles may be applied to any application environment
-(third-party or in-house)&nbsp; with similar characteristics.&nbsp;
-Python applications running as CGIplus scripts using the PyRTE <b>must</b>
-be
-activated via DCL wrappers as illustrated above (in part due to mapping
-requirements).<br>
-<br>
-With CGIplus persistent applications configuration or code changes will
-in all probability require a 'restart' of the application using one or
-other of:<br>
-<div style="margin-left: 40px;">
-<pre>$ HTTPD/DO=PURGE<br>$ HTTPD/DO=DELETE<br><br></pre>
-</div>
-<div style="margin-left: 40px;"></div>
-<span style="font-family: helvetica,arial,sans-serif;"></span>
-<h3
- style="text-decoration: underline; font-family: helvetica,arial,sans-serif;"><a
- name="Problems"></a>Problems?</h3>
-<ul style="font-family: helvetica,arial,sans-serif;">
-  <li> With the PyRTE kit ... <a
- href="mailto:Mark.Daniel@wasd.vsm.com.au">Mark.Daniel@wasd.vsm.com.au</a>
-  </li>
-  <li> With the VMS Python kit ... <a
- href="mailto:jf.pieronne@laposte.net">jf.pieronne@laposte.net</a><br>
-  </li>
-  <li> The info-WASD mailing list <br>
-  </li>
-</ul>
-<p style="font-family: helvetica,arial,sans-serif;"> Unfortunately the
-author of the PyRTE interface is such a Python
-novice he is not in any position to answer queries about Python
-"programming" or
-usage.&nbsp; There is the VMS Python Wiki<br>
-</p>
-<p style="font-family: helvetica,arial,sans-serif; margin-left: 40px;"><a
- href="http://vmspython.dyndns.org/">http://vmspython.dyndns.org/</a><br>
-</p>
-<p style="font-family: helvetica,arial,sans-serif;">and support forum<br>
-</p>
-<p style="font-family: helvetica,arial,sans-serif; margin-left: 40px;"><a
- href="http://vmspython.dyndns.org/piforum/index.py">http://vmspython.dyndns.org/piforum/index.py</a><br>
-</p>
-<p style="font-family: helvetica,arial,sans-serif;">for VMS Python
-issues.&nbsp; If there's an obvious behavioural problem with PyRTE then
-contact the author or use the info-WASD mailing list.<br>
-<br>
-</p>
-<h3
- style="text-decoration: underline; font-family: helvetica,arial,sans-serif;"><a
- name="Acknowlegements"></a>Acknowlegements</h3>
-<p style="font-family: helvetica,arial,sans-serif;"> Many thanks to
-Jean-Fran&ccedil;ois Pi&eacute;ronne for his initial port of Python to
-VMS and his energetic, ongoing maintenance of the product.<br>
-<br>
-</p>
-<hr style="font-family: helvetica,arial,sans-serif;" align="left"
- noshade="noshade" size="1" width="65%">
-</body>
-</html>
+</PRE>
+
+<H3>WSGI Output Buffering</H3>
+
+<P> PEP 333 specifies that WSGI should not buffer output and pyRTE complies but
+some tools (like Mercurial) don't buffer internally themselves and end up
+sending many very small records.  This is obviously inefficient.  If buffered
+the throughput boost for Mercurial is about x4.  Well worth having for
+specific Web applications.
+
+<P> This forced buffering may be enabled on a per-application basis using a
+mapping rule, for example
+
+<PRE CLASS="code">
+set /mercurial/* script=param=PYRTE=/WSGI=BUFFER
+</PRE>
+
+or by defining the logical name
+
+<PRE CLASS="code">
+$ DEFINE /JOB PYRTE_WSGI_FORCE_BUFFERING TRUE
+</PRE>
+
+in a wrapper procedure.
+
+<H3>Example WSGI Scripts</H3>
+
+<P> The following scripts may be used to confirm the environment is
+functioning.
+
+<UL>
+<LI><A HREF="/py-bin/wsgi_test1.py">/py-bin/wsgi_test1.py</A> 
+<LI><A HREF="/py-bin/wsgi_test2.py">/py-bin/wsgi_test2.py</A>
+<LI><A HREF="/py-bin/wsgi_test3.py">/py-bin/wsgi_test3.py</A>
+<LI><A HREF="/py-bin/wsgi_test4.py">/py-bin/wsgi_test4.py</A>
+</UL>
+
+<P> The Python code in the script may be inspected from the source directory:
+
+<BLOCKQUOTE>
+<A HREF="/ht_root/src/python/scripts/">/ht_root/src/python/scripts/</A>
+</BLOCKQUOTE>
+
+<P> There are also equivalent <TT>wsgiref</TT> (the Python reference
+implementation) scripts available for comparison.  Just add <TT>ref</TT> to the
+<TT>wsgi</TT> in the script name.
+
+<A NAME="lever">
+<H2>Leveraging PyRTE</H2>
+</A>
+
+<P> Python scripts activated using the default persistent engine generally have
+low-latency, low-system-impact characteristics and seem to perform reliably and
+efficiently.  The PyRTE generally handles all the WASD server interaction
+requirements.  However there may be occasions where the application itself
+benefits from being persistent (many Python Web application are written with
+this in mind) or where more control needs to be exercised by the application
+designer.  The WASD PyRTE provides a WASD Python module that provides an API
+for some of these aspects.  Rather than clutter this document with such arcane
+detail the description may be found in the prologue to the PyRTE source code:
+
+<BLOCKQUOTE>
+<A HREF="/ht_root/src/python/pyrte.c">/ht_root/src/python/pyrte.c</A>
+</BLOCKQUOTE>
+
+<P> An example of where an application benefits from an explicitly CGIplus
+activation is MoinMoin:
+
+<UL>
+<LI><A HREF="http://moinmoin.wikiwikiweb.de/">http://moinmoin.wikiwikiweb.de/</A>
+<LI><A HREF="http://vmspython.dyndns.org/MoinMoin">http://vmspython.dyndns.org/MoinMoin</A>
+<LI><A HREF="http://vmspython.dyndns.org/DownloadAndInstallationMoinMoin">http://vmspython.dyndns.org/DownloadAndInstallationMoinMoin</A>
+</UL>
+
+<P> MoinMoin is generally run independently to a system's primary Web server
+using  the embedded Web server available for Python.  Reverse proxy is often
+then use to provide and control access through to the persistent MoinMoin
+server.
+
+<P> Using the same principle of keeping MoinMoin persistent (for the obvious
+latency and efficiency benefits) it can be run and controlled directly by the
+WASD Web server using a CGIplus wrapper DCL procedure and a little Python glue
+(directly derived from persistence code already present in the MoinMoin
+package).
+
+<BLOCKQUOTE>
+<A HREF="/ht_root/src/python/moincgiplus.com">/ht_root/src/python/moincgiplus.com</A>
+</BLOCKQUOTE>
+
+<P> The same principles may be applied to any application environment
+(third-party or in-house)  with similar characteristics.  Python applications
+running as CGIplus scripts using the PyRTE must be activated via DCL wrappers
+as illustrated above (in part due to mapping requirements).
+
+<P> With CGIplus persistent applications configuration or code changes will in
+all probability require a 'restart' of the application using one or other of:
+
+<PRE CLASS="code">
+$ HTTPD/DO=PURGE
+$ HTTPD/DO=DELETE
+</PRE>
+
+<A NAME="problems">
+<H2>Problems?</H2>
+</A>
+
+<UL>
+<LI> With the PyRTE kit ... Mark.Daniel@wasd.vsm.com.au
+<LI> With the VMS Python kit ... jf.pieronne@laposte.net
+<LI> The info-WASD mailing list
+</UL>
+
+<P> Unfortunately the author of the PyRTE interface is such a Python novice he
+is not in any position to answer queries about Python "programming" or usage.
+There is the VMS Python Wiki
+
+<BLOCKQUOTE>
+<A HREF="http://vmspython.dyndns.org/">http://vmspython.dyndns.org/</A>
+</BLOCKQUOTE>
+
+<P> and support forum
+
+<BLOCKQUOTE>
+<A HREF="http://vmspython.dyndns.org/piforum/index.py">http://vmspython.dyndns.org/piforum/index.py</A>
+</BLOCKQUOTE>
+
+<P> for VMS Python issues.  If there's an obvious behavioural problem with
+PyRTE then contact the author or use the info-WASD mailing list.
+
+<A NAME="ackn">
+<H2>Acknowlegements</H2>
+</A>
+
+<P> Many thanks to Jean-Fran�ois Pi�ronne for his initial port of Python to VMS
+and his energetic, ongoing maintenance of the product.
+
+<BR><HR ALIGN=left SIZE=1 NOSHADE><BR>
+
+</BODY>
+</HTML>