Funcs¶
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.
- WebUtils.Funcs.htmlDecode(s, codes=(('"', '"'), ('>', '>'), ('<', '<'), ('&', '&')))¶
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().
The optional ‘codes’ parameter allows passing custom translations.
- WebUtils.Funcs.htmlEncode(what, codes=(('&', '&'), ('<', '<'), ('>', '>'), ('"', '"')))¶
Return the HTML encoded version of the given object.
The optional ‘codes’ parameter allows passing custom translations.
- WebUtils.Funcs.htmlEncodeStr(s, codes=(('&', '&'), ('<', '<'), ('>', '>'), ('"', '"')))¶
Return the HTML encoded version of the given string.
This is useful to display a plain ASCII text string on a web page.
The optional ‘codes’ parameter allows passing custom translations.
- WebUtils.Funcs.htmlForDict(d, addSpace=None, filterValueCallBack=None, maxValueLength=None, topHeading=None, isEncoded=None)¶
Return HTML string with a table where each row is a key/value pair.
- WebUtils.Funcs.normURL(path)¶
Normalizes a URL path, like os.path.normpath.
Acts on a URL independent of operating system environment.
- WebUtils.Funcs.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.
- WebUtils.Funcs.urlDecode(string, encoding='utf-8', errors='replace')¶
Like unquote(), but also replace plus signs by spaces, as required for unquoting HTML form values.
unquote_plus(‘%7e/abc+def’) -> ‘~/abc def’
- WebUtils.Funcs.urlEncode(string, safe='', encoding=None, errors=None)¶
Like quote(), but also replace ‘ ‘ with ‘+’, as required for quoting HTML form values. Plus signs in the original string are escaped unless they are included in safe. It also does not have safe default to ‘/’.