Package aquarium :: Package wsadaptor :: Module WebServerAdaptor :: Class WebServerAdaptor
[show private | hide private]
[frames | no frames]

Class WebServerAdaptor

Known Subclasses:
CGIAdaptor, FastCGIAdaptor, GlassAdaptor, ModPythonAdaptor, WSGIAdaptor

This is the base class for wsadaptor classes.

This class and its sub-classes act as abstraction layers for all the different types of Web server setups. Although CGI is very flexible and standardized, it's not very fast. Similarly, although mod_python is very fast, it's not very standard. Furthermore, there will surely be other environments one day. Hence it's our goal here to permit Aquarium to be used in new environments without any environment-specific code needing to be added to application-level code.

You'll notice that this class does not subclass AquariumClass (whose main purpose is to receive an instance of Context on initialization). In fact, this class is instantiated before the main Aquarium class is instantiated, and the main Aquarium class will receive an instance of this class in its constructor. That instance will be stored in self._ctx.wsa. This permits the same site to be run under multiple different environments without even a change to the AquariumProperties file.

The following methods should be overriden by subclasses: setResponseCode, write, writeHeaders, getCgiEnv, getForm.


Method Summary
  getCgiEnv(self)
Return CGI-like environmental variables.
  getForm(self)
Instantiate some cgi.FieldStorage and return the instance.
  setResponseCode(self, code, msg)
Set the Web server response code and message.
  write(self, s)
Output a string.
  writeHeaders(self, headersList)
Output a list of header strings.

Method Details

getCgiEnv(self)

Return CGI-like environmental variables.

getForm(self)

Instantiate some cgi.FieldStorage and return the instance.

setResponseCode(self, code=200, msg='Script output follows')

Set the Web server response code and message.

Keword arguments:

code
The default means "OK".
msg
The default is "Script output follows".

This base class does nothing.

write(self, s)

Output a string.

This base class simply uses print.

writeHeaders(self, headersList)

Output a list of header strings.

The list will contains tuples like:

("Content-type", "text/html")

This base class simply uses self.write.

If your environment requires a response code to be set before headers are set, you should call setResponseCode with no arguments if it hasn't already been called.


Generated by Epydoc 2.1 on Mon Jan 1 16:34:19 2007 http://epydoc.sf.net