WebUtils.Funcs | index /usr/local/share/webware/WebUtils/Funcs.py

`WebUtils.Funcs
This module provides some basic functions that are useful
in HTML and web development.
You can safely import * from WebUtils.Funcs if you like.
TO DO
* Document the 'codes' arg of htmlEncode/Decode.`

Functions

``

htmlDecode(s, codes=[['"', '&quot;'], ['>', '&gt;'], ['<', '&lt;'], ['&', '&amp;']])
  `Return the ASCII decoded version of the given HTML string.
  This does NOT remove normal HTML tags like <p>.
  It is the inverse of htmlEncode().`

htmlEncode(what, codes=[['&', '&amp;'], ['<', '&lt;'], ['>', '&gt;'], ['"', '&quot;']])

htmlEncodeStr(s, codes=[['&', '&amp;'], ['<', '&lt;'], ['>', '&gt;'], ['"', '&quot;']])
  `Return the HTML encoded version of the given string.
  This is useful to display a plain ASCII text string on a web page.`

htmlForDict(dict, addSpace=None, filterValueCallBack=None, maxValueLength=None, topHeading=None, isEncoded=None)
  `Return an HTML string with a table where each row is a key-value pair.`

normURL(path)
  `Normalizes a URL path, like os.path.normpath.
  Acts on a URL independant of operating system environment.`

requestURI(env)
  `Return the request URI for a given CGI-style dictionary.
  Uses REQUEST_URI if available, otherwise constructs and returns it
  from SCRIPT_URL, SCRIPT_NAME, PATH_INFO and QUERY_STRING.`

urlDecode(s)
  `Return the decoded version of the given string.
  Note that invalid URLs will not throw exceptions.
  For example, incorrect % codings will be ignored.
  Identical to urllib.unquote_plus(s) in Python 2.4,
  but faster and more exact for older Python versions.`

urlEncode(s)
  `Return the encoded version of the given string.
  The resulting string is safe for using as a URL.
  Identical to urllib.quote_plus(s) in Python 2.4,
  but faster for older Python versions.`

Data
`` |  | c = '\xff' htmlCodes = [['&', '&amp;'], ['<', '&lt;'], ['>', '&gt;'], ['"', '&quot;']] htmlCodesReversed = [['"', '&quot;'], ['>', '&gt;'], ['<', '&lt;'], ['&', '&amp;']] htmlForNone = '-' i = 255