Ticket #126: post_data.patch
File post_data.patch, 3.2 KB (added by , 19 years ago) |
---|
-
wsgi.py
20 20 # Populates self._post and self._files 21 21 if self.environ['REQUEST_METHOD'] == 'POST': 22 22 post_data = self.environ['wsgi.input'].read(int(self.environ["CONTENT_LENGTH"])) 23 self._post_data = post_data 23 24 if self.environ.get('CONTENT_TYPE', '').startswith('multipart'): 24 25 header_dict = dict([(k, v) for k, v in self.environ.items() if k.startswith('HTTP_')]) 25 26 self._post, self._files = httpwrappers.parse_file_upload(header_dict, post_data) … … 89 90 90 91 def _set_user(self, user): 91 92 self._user = user 93 94 def _set_post_data(self,post_data): 95 self._post_data = post_data 92 96 97 def _get_post_data(self): 98 if not hasattr(self, '_post_data'): 99 self._load_post_and_files() 100 if hasattr(self, '_post_data'): 101 return(self._post_data) 102 else: 103 return("") 104 93 105 GET = property(_get_get, _set_get) 94 106 POST = property(_get_post, _set_post) 95 107 COOKIES = property(_get_cookies, _set_cookies) … … 97 109 REQUEST = property(_get_request) 98 110 session = property(_get_session, _set_session) 99 111 user = property(_get_user, _set_user) 112 post_data = property(_get_post_data,_set_post_data) 100 113 101 114 class WSGIHandler: 102 115 def __init__(self): -
modpython.py
21 21 22 22 def _load_post_and_files(self): 23 23 "Populates self._post and self._files" 24 self._post_data = self._req.read() 24 25 if self._req.headers_in.has_key('content-type') and self._req.headers_in['content-type'].startswith('multipart'): 25 self._post, self._files = httpwrappers.parse_file_upload(self._req.headers_in, self._ req.read())26 self._post, self._files = httpwrappers.parse_file_upload(self._req.headers_in, self._post_data) 26 27 else: 27 self._post, self._files = httpwrappers.QueryDict(self._ req.read()), datastructures.MultiValueDict()28 self._post, self._files = httpwrappers.QueryDict(self._post_data), datastructures.MultiValueDict() 28 29 29 30 def _get_request(self): 30 31 if not hasattr(self, '_request'): … … 115 116 def _set_user(self, user): 116 117 self._user = user 117 118 119 def _set_post_data(self,post_data): 120 self._post_data = post_data 121 122 def _get_post_data(self): 123 if not hasattr(self, '_post_data'): 124 self._load_post_and_files() 125 if hasattr(self, '_post_data'): 126 return(self._post_data) 127 else: 128 return("") 129 130 118 131 GET = property(_get_get, _set_get) 119 132 POST = property(_get_post, _set_post) 120 133 COOKIES = property(_get_cookies, _set_cookies) … … 123 136 REQUEST = property(_get_request) 124 137 session = property(_get_session, _set_session) 125 138 user = property(_get_user, _set_user) 126 139 post_data = property(_get_post_data,_set_post_data) 140 127 141 class ModPythonHandler: 128 142 def __init__(self): 129 143 self._request_middleware = self._view_middleware = self._response_middleware = None