# 1.1 `web` -- Web modules

The `web` module provides some basic utility functions and objects which are used throughout the Web Modules.

Version Information

The `web` module has the following variables:

`web.version_info`

  A tuple similar to `sys.version_info` in the form `(major version, minor version, revision, release candidate, status)`

`web.version`
  The version as a string eg `'0.4.0rc1'`

`web.name`
  The name of the modules as a string

`web.date`
  The date of the release as a string in the format `'yyyy-mm-dd'`.

`web.status`
  The release status of the code. For example `'beta'`

Useful Objects

The `web` module provides the following objects:

`web.cgi`
  An object based on the cgi.FieldStorage() object.

  The `web.cgi` object is used to access CGI environment variables such as information submitted from forms or appended to a URL or information about the user's browser. `web.cgi` provides a dictionary-like interface to all the sumbitted CGI variables.

  Warning: Creating a `cgi.FieldStorage` object can destroy data that would be used in subsequent creating subsequent `cgi.FieldStorage` objects so you should only use the `web.cgi` object which will be created first in order to avoid this problem.

  See Also:

  `cgi` Module Documentation
    The `cgi` module documentation distributed with Python has more information about `cgi.FieldStorage` objects and a full functional specification.

Useful Functions

`header`( | [type='text/html'])

  Returns a Content-type HTTP header

  type
    The content-type to output

`encode`( | html[, mode='url'])

  Encode a string for use in an HTML document

  html
    The string to encode

  mode
    If mode is `'url'` the html string is encoded for use in a URL. If mode is `'form'` html is encoded for use in a form field.

    Warning: The HTTP protocol doesn't specify the maximum length of URLs but to be absolutely safe try not to let them be longer than 256 characters. Internet Explorer supports URLs of up to 2,083 characters. Any long strings are better off encoded to be put as hidden values in a form with `method="POST"` rather than encoded and embedded in URLs. Information sent using `POST` is sent in the HTTP header where there is no limit to the length.

    Another reason not to encode larege amounts if information in URLs is that doing so may also result in strange behaviour in certain browsers.