The values of :attr:`forms` and :attr:`files` combined into a single :class:`FormsDict`. Values are either strings (form values) or instances of :class:`cgi.FieldStorage` (file uploads).
(self)
| 1376 | |
| 1377 | @DictProperty('environ', 'bottle.request.post', read_only=True) |
| 1378 | def POST(self): |
| 1379 | """ The values of :attr:`forms` and :attr:`files` combined into a single |
| 1380 | :class:`FormsDict`. Values are either strings (form values) or |
| 1381 | instances of :class:`cgi.FieldStorage` (file uploads). |
| 1382 | """ |
| 1383 | post = FormsDict() |
| 1384 | # We default to application/x-www-form-urlencoded for everything that |
| 1385 | # is not multipart and take the fast path (also: 3.1 workaround) |
| 1386 | if not self.content_type.startswith('multipart/'): |
| 1387 | body = tonat(self._get_body_string(self.MEMFILE_MAX), 'latin1') |
| 1388 | for key, value in _parse_qsl(body): |
| 1389 | post[key] = value |
| 1390 | return post |
| 1391 | |
| 1392 | safe_env = {'QUERY_STRING': ''} # Build a safe environment for cgi |
| 1393 | for key in ('REQUEST_METHOD', 'CONTENT_TYPE', 'CONTENT_LENGTH'): |
| 1394 | if key in self.environ: safe_env[key] = self.environ[key] |
| 1395 | args = dict(fp=self.body, environ=safe_env, keep_blank_values=True) |
| 1396 | |
| 1397 | if py3k: |
| 1398 | args['encoding'] = 'utf8' |
| 1399 | post.recode_unicode = False |
| 1400 | data = cgi.FieldStorage(**args) |
| 1401 | self['_cgi.FieldStorage'] = data #http://bugs.python.org/issue18394 |
| 1402 | data = data.list or [] |
| 1403 | for item in data: |
| 1404 | if item.filename is None: |
| 1405 | post[item.name] = item.value |
| 1406 | else: |
| 1407 | post[item.name] = FileUpload(item.file, item.name, |
| 1408 | item.filename, item.headers) |
| 1409 | return post |
| 1410 | |
| 1411 | @property |
| 1412 | def url(self): |
nothing calls this directly
no test coverage detected