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
`` |  | __builtin__.object CGIWrapper
class CGIWrapper(__builtin__.object)
`` | `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.` environ(self) `Get the environment for the request.` 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=True) `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=False) 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 object>) `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 with Content-Type entry.` 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={'OSVERSION': '901000', 'FTP_TIMEOUT': '900', 'P...', 'UNAME_s': 'FreeBSD', 'MACHINE_ARCH': 'amd64'}) `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.` Data descriptors defined here: __dict__ `dictionary for instance variables (if defined)` __weakref__ `list of weak references to the object (if defined)`

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(d, 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 = 1365450140.858211 version = (1, 1, 0)