CGIWrapper.CGIWrapper | index /usr/local/share/webware/CGIWrapper/CGIWrapper.py

`CGIWrapper.py
Webware for Python
See the CGIWrapper.html documentation for more information.`

Modules

``

WebUtils cgi | os sys | traceback |

Classes

``

MiscUtils.NamedValueAccess.NamedValueAccess
  CGIWrapper

class CGIWrapper(MiscUtils.NamedValueAccess.NamedValueAccess)
`` | `The CGI Wrapper class. A CGI wrapper executes a target script and provides various services for both the script and website developer and the administrator. See the CGIWrapper.html documentation for full information.`

Methods defined here:

__init__(self)

config(self)
  `Return the configuration for the CGIWrapper.
  This is a combination of defaultConfig() and userConfig().
  This method does no caching.`

configFilename(self)
  `Return the filename of the optional configuration file.`

defaultConfig(self)
  `Return a dictionary with the default configuration.
  Subclasses could override to customize the values
  or where they're taken from.`

deliver(self)
  `Deliver the HTML.
  This is used for the output that came from the script being served,
  or from our own error reporting.`

docType(self)

emailException(self, html, excInfo=None)
  `Email an exception.`

enhanceThePath(self)
  `Enhance sys.path according to our configuration.`

handleException(self, excInfo)
  `Handle an exception in the target script.
  Invoked by self when an exception occurs in the target script.
  <code>excInfo</code> is a sys.exc_info()-style tuple of information
  about the exception.`

htmlDebugInfo(self)
  `Return an HTML page with debugging info on the current exception.
  Used by handleException().`

htmlErrorPage(self, showDebugInfo=1)
  `Return an HTML page explaining that there is an error.
  There could be more options in the future so using named arguments
  (e.g., 'showDebugInfo=1') is recommended. Invoked by handleException().`

htmlErrorPageFilename(self)
  `Construct a filename for an HTML error page.
  This filename does not include the 'ErrorMessagesDir' setting.`

logExceptionToConsole(self, stderr=<__main__.OutputCatcher instance at 0x82ca12c>)
  `Log an exception in the target script.
  Logs the time, script name and traceback to the console
  (typically stderr). This usually results in the information
  appearing in the web server's error log. Used by handleException().`

logExceptionToDisk(self, errorMsgFilename=None, excInfo=None)
  `Write exception info to the log file.
  Writes a tuple containing (date-time, filename, pathname,
  exception-name, exception-data, error report filename)
  to the errors file (typically 'Errors.csv') in CSV format.
  Invoked by handleException().`

makeFieldStorage(self)
  `Return a default field storage object created from the cgi module.`

makeHeaders(self)
  `Return a default header dictionary containing {'Content-type': 'text/html'}.`

requireEnvs(self, names)
  `Check that given environment variable names exist.
  If they don't, a basic HTML error message is printed and we exit.`

reset(self)
  `Reset CGI output.
  Used by handleException() to clear out the current CGI output results
  in preparation of delivering an HTML error message page.
  Currently resets headers and deletes cookies, if present.`

saveHTMLErrorPage(self, html)
  `Save the given HTML error page for later viewing by the developer.
  Returns the filename used. Invoked by handleException().`

scriptPathname(self)
  `Return the full pathname of the target script.
  Scripts that start with an underscore are special -- they run
  out of the same directory as the CGI Wrapper and are typically
  CGI Wrapper support scripts.`

serve(self, environ={'GROUP': 'wheel', 'FTP_TIMEOUT': '900', 'REMOTE...e', 'UNAME_s': 'FreeBSD', 'MACHINE_ARCH': 'i386'})
  `Serve a request.`

setting(self, name)
  `Return the value of a particular setting in the configuration.`

userConfig(self)
  `Return a dictionary with the user configuration.
  This are overrides found in the optional configuration file,
  or {} if there is no such file. The config filename is taken
  from configFilename().`

version(self)

writeScriptLog(self)
  `Write an entry to the script log file.
  Uses settings ScriptLogFilename and ScriptLogColumns.`

Methods inherited from MiscUtils.NamedValueAccess.NamedValueAccess:

handleUnknownSetKey(self, key)

hasValueForKey(self, key)
  `Check whether key is available.
  Returns true if the key is available, although that does not guarantee
  that there will not be errors caused by retrieving the key.`

hasValueForName(self, keysString)
  `Check whether name is available.`

resetKeyBindings(self)
  `Rest all key bindings, releasing alreaedy referenced values.`

setValueForKey(self, key, value)
  `Set value for a given key.
  Suppose key is 'foo'.
  This method sets the value with the following precedence:
  1. Public attributes before private attributes
  2. Methods before non-methods
  More specifically, this method then uses one of the following:
  @@ 2000-03-04 ce: fill in
  ... or invokes handleUnknownSetKey().`

valueForKey(self, key, default=<class MiscUtils.NoDefault at 0x81cfa1c>)
  `Get value for given key.
  Suppose key is 'foo'.
  This method returns the value with the following precedence:
  1. Methods before non-methods
  2. Public attributes before private attributes
  More specifically, this method then returns one of the following:
  * foo()
  * _foo()
  * self.foo
  * self._foo
  ... or default, if it was specified,
  otherwise invokes and returns result of valueForUnknownKey().
  Note that valueForUnknownKey() normally returns an exception.
  See valueForName() which is a more advanced version of this method
  that allows multiple, qualified keys.`

valueForKeySequence(self, listOfKeys, default=None)
  `Get the value for the given list of keys.`

valueForName(self, keysString, default=None)
  `Get the value for the given keysString.
  This is the more advanced version of valueForKey(), which can only
  handle single names. This method can handle
  'foo', 'foo1.foo2', 'a.b.c.d', etc.
  It will traverse dictionaries if needed.`

valueForUnknownKey(self, key, default)

valuesForNames(self, keys, default=None, defaults=None, forgive=0, includeNames=0)
  `Get all values for given names.
  Returns a list of values that match the given keys, each of which is
  passed through valueForName() and so could be of the form 'a.b.c'.
  keys and defaults are sequences.
  default is any kind of object.
  forgive and includeNames are flags.
  If default is not None, then it is substituted when a key is not found.
  Otherwise, if defaults is not None, then it's corresponding/parallel
  value for the current key is substituted when a key is not found.
  Otherwise, if forgive is true, then unknown keys simply don't produce
  any values.
  Otherwise, if default and defaults are None, and forgive is false,
  then the unknown keys will probably raise an exception through
  valueForUnknownKey() although that method can always return
  a final, default value.
  if keys is None, then None is returned.
  If keys is an empty list, then None is returned.
  Often these last four arguments are specified by key.
  Examples:
  names = ['origin.x', 'origin.y', 'size.width', 'size.height']
  obj.valuesForNames(names)
  obj.valuesForNames(names, default=0.0)
  obj.valuesForNames(names, defaults=[0.0, 0.0, 100.0, 100.0])
  obj.valuesForNames(names, forgive=0)
  @@ 2000-03-04 ce: includeNames is only supported when forgive=1.
  It should be supported for the other cases.
  It should be documented.
  It should be included in the test cases.`

Functions

``

StringIO(...)
  `StringIO([s]) -- Return a StringIO-like stream for reading or writing`

asctime(...)
  `asctime([tuple]) -> string
  Convert a time tuple to a string, e.g. 'Sat Jun 06 16:26:11 1998'.
  When the time tuple is not present, current time as returned by localtime()
  is used.`

docType()
  `Return a standard HTML document type`

htDictionary(dict, addSpace=None)
  `Returns an HTML table where each row is a key-value pair.`

htTable(listOfDicts, keys=None)
  `Return an HTML table for a list of dictionaries.
  The listOfDicts parameter is expected to be a list of
  dictionaries whose keys are always the same. This function
  returns an HTML string with the contents of the table.
  If keys is None, the headings are taken from the first row in
  alphabetical order.
  Returns an empty string if listOfDicts is none or empty.
  Deficiencies: There's no way to influence the formatting or to
  use column titles that are different from the keys.`

htTitle(name)
  `Return an HTML section title.`

localtime(...)
  `localtime([seconds]) -> (tm_year,tm_mon,tm_mday,tm_hour,tm_min,tm_sec,tm_wday,tm_yday,tm_isdst)
  Convert seconds since the Epoch to a time tuple expressing local time.
  When 'seconds' is not passed in, convert the current time instead.`

main()

osIdTable()
  `Get all OS id information.
  Returns a list of dictionaries containing id information such
  as uid, gid, etc., all obtained from the os module.
  Dictionary keys are 'name' and 'value'.`

time(...)
  `time() -> floating point number
  Return the current time in seconds since the Epoch.
  Fractions of a second may be present if the system clock provides them.`

Data
`` |  | serverStartTime = 1221902611.6623709 version = (1, 0, 0, 'rc1')