Package invenio :: Module webinterface_handler_wsgi_utils
[hide private]
[frames] | no frames]

Module webinterface_handler_wsgi_utils

source code

mod_python->WSGI Framework utilities

This code has been taken from mod_python original source code and rearranged here to easying the migration from mod_python to wsgi.

The code taken from mod_python is under the following License.

Classes [hide private]
  table
  metaCookie
  Cookie
This class implements the basic Cookie functionality.
  Field
  StringField
This class is basically a string with added attributes for compatibility with std lib cgi.py.
  FieldList
  FieldStorage
Functions [hide private]
 
exists_config_define(dummy) source code
 
_parse_cookie(str, Class, names=None) source code
 
add_cookies(req, cookies)
Sets one or more cookie in outgoing headers and adds a cache directive so that caches don't cache the cookie.
source code
 
get_cookies(req, Class=<class 'invenio.webinterface_handler_wsgi_utils.Cookie'>, **kw)
A shorthand for retrieveing and parsing cookies given a Cookie class.
source code
 
get_cookie(req, name, Class=<class 'invenio.webinterface_handler_wsgi_utils.Cookie'>, **kw) source code
 
parse_header(line)
Parse a Content-type like header.
source code
 
apply_fs_data(object, fs, **args)
Apply FieldStorage data to an object - the object must be callable.
source code
(string, string)
handle_file_post(req, allowed_mimetypes=None)
Handle the POST of a file.
source code
Variables [hide private]
  _path_cache = {}
  _path_cache_lock = threading.Lock()
  _cookiePattern = re.compile(r'(?x)[, ]*(?P<key>[^; =]+) *(= *)...
  readBlockSize = 65368
The classes below are a (almost) a drop-in replacement for the standard cgi.py FieldStorage class.
  RE_CDISPOSITION_FILENAME = re.compile(r'filename=(?P<filename>...
  __package__ = 'invenio'
Function Details [hide private]

get_cookies(req, Class=<class 'invenio.webinterface_handler_wsgi_utils.Cookie'>, **kw)

source code 

A shorthand for retrieveing and parsing cookies given a Cookie class. The class must be one of the classes from this module.

parse_header(line)

source code 

Parse a Content-type like header.

Return the main content-type and a dictionary of options.

apply_fs_data(object, fs, **args)

source code 

Apply FieldStorage data to an object - the object must be callable. Examine the args, and match then with fs data, then call the object, return the result.

handle_file_post(req, allowed_mimetypes=None)

source code 

Handle the POST of a file.

Returns: (string, string)
the a tuple with th full path to the file saved on disk, and it's mimetype as provided by the request.

Variables Details [hide private]

_cookiePattern

Value:
re.compile(r'(?x)[, ]*(?P<key>[^; =]+) *(= *)?(?P<val>"(?:[^\\"]|\\.)*\
"|[^;]*)\s*;?')

readBlockSize

The classes below are a (almost) a drop-in replacement for the standard cgi.py FieldStorage class. They should have pretty much the same functionality.

These classes differ in that unlike cgi.FieldStorage, they are not recursive. The class FieldStorage contains a list of instances of Field class. Field class is incapable of storing anything in it.

These objects should be considerably faster than the ones in cgi.py because they do not expect CGI environment, and are optimized specifically for Apache and mod_python.

Value:
65368

RE_CDISPOSITION_FILENAME

Value:
re.compile(r'filename=(?P<filename>[\w\.]*)')