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)
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(dict)
Return the request URI for a given CGI-style dictionary.
 
Uses REQUEST_URI if available, otherwise constructs and returns it
from SCRIPT_NAME, PATH_INFO and QUERY_STRING.
urlDecode(s)
Return the decoded version of the given string.
 
Note that invalid URLs will throw exceptons.
For example, a URL whose % coding is incorrect.
urlEncode(s)
Return the encoded version of the given string, safe for using as a URL.

 
Data
        c = '/'
digits = '0123456789'
htmlCodes = [['&', '&amp;'], ['<', '&lt;'], ['>', '&gt;'], ['"', '&quot;']]
htmlCodesReversed = [['"', '&quot;'], ['>', '&gt;'], ['<', '&lt;'], ['&', '&amp;']]
htmlForNone = '-'
i = 255
letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'