''' Created on Jan 31, 2010 @author: epeli ''' import cgi class SokkeliRequest(object): _get = None _post = None def __init__(self, req): self.req = req self.method = req.method def __getattr__(self, name): """ Called when an attribute lookup has not found the attribute in the usual places. """ return getattr(self.req, name) @property def post(self): if not self._post: self._post = cgi.parse_qs( self.req.read() ) return self._post @property def get(self): if not self._get: if not self.req.args: self._get = {} else: self._get = cgi.parse_qs(self.req.args, True) return self._get @property def request(self): foo = self.get.copy() foo.update(self.post) return foo