|
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 0x4851c18c>)
- 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={'FTP_TIMEOUT': '900', 'INDEXFILE': 'INDEX-7', '...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 0x4842fa1c>)
- 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.
|