Module pyweb :: Class httpenv
[show private | hide private]
[frames | no frames]

Class httpenv


Instances of this class hold all pertinent information relating to the current http request.

Info includes:
Method Summary
  __init__(self, **kw)
Creates an http env object, containing form, URL and cookie data
  log(self, msg)
  retrieveData(self)
Extracts from cookies '__data', '__data_0', '__data_1', ...
  saveData(self)
Extracts our 'data' attribute, encodes it, signs it, and stores it into one or more cookies in the form '__data', '__data_0', '__data_1', ...
  setDataExpiry(self, seconds)
Sets the expiry date of the cookie
  seterror(self, errtype)
Formats a loud error message for insertion at the top of the page

Method Details

__init__(self, **kw)
(Constructor)

Creates an http env object, containing form, URL and cookie data

retrieveData(self)

Extracts from cookies '__data', '__data_0', '__data_1', ... the encoded dictionary that forms the attribute 'data'.

Authenticates this encoded dictionary via hmac/sha1

refer to the saveData method for info of how the data dict gets broken into multiple cookies

saveData(self)

Extracts our 'data' attribute, encodes it, signs it, and stores it into one or more cookies in the form '__data', '__data_0', '__data_1', ...

If there's a lot of data, it will need to be broken up into multiple cookies. So here's the encoding scheme:
  • if the pickled data size < 4096 - 40 - 3, then the format is: '000sd', where 's' is the hmac/sha1 signature in hex (40 bytes), and 'd' is the actual data
  • if the pickled data size is larger, then the format of the '__data' cookie is 'nnns', where 'nnn' is the number of cookie blocks expressed in decimal (3 chars), s is the 40-char hmac/sha1 signature, and the actual data blocks are stored in subsequent cookies named '__data_001', ..., '__data_nnn'

setDataExpiry(self, seconds)

Sets the expiry date of the cookie

seterror(self, errtype)

Formats a loud error message for insertion at the top of the page

Generated by Epydoc 2.0 on Sat Feb 7 20:08:06 2004 http://epydoc.sf.net