MCPcopy Index your code
hub / github.com/fluentpython/example-code-2e / POST

Method POST

21-async/mojifinder/bottle.py:1215–1247  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1213
1214 @DictProperty('environ', 'bottle.request.post', read_only=True)
1215 def POST(self):
1216 """ The values of :attr:`forms` and :attr:`files` combined into a single
1217 :class:`FormsDict`. Values are either strings (form values) or
1218 instances of :class:`cgi.FieldStorage` (file uploads).
1219 """
1220 post = FormsDict()
1221 # We default to application/x-www-form-urlencoded for everything that
1222 # is not multipart and take the fast path (also: 3.1 workaround)
1223 if not self.content_type.startswith('multipart/'):
1224 pairs = _parse_qsl(tonat(self._get_body_string(), 'latin1'))
1225 for key, value in pairs:
1226 post[key] = value
1227 return post
1228
1229 safe_env = {'QUERY_STRING':''} # Build a safe environment for cgi
1230 for key in ('REQUEST_METHOD', 'CONTENT_TYPE', 'CONTENT_LENGTH'):
1231 if key in self.environ: safe_env[key] = self.environ[key]
1232 args = dict(fp=self.body, environ=safe_env, keep_blank_values=True)
1233 if py31:
1234 args['fp'] = NCTextIOWrapper(args['fp'], encoding='utf8',
1235 newline='\n')
1236 elif py3k:
1237 args['encoding'] = 'utf8'
1238 data = cgi.FieldStorage(**args)
1239 self['_cgi.FieldStorage'] = data #http://bugs.python.org/issue18394#msg207958
1240 data = data.list or []
1241 for item in data:
1242 if item.filename:
1243 post[item.name] = FileUpload(item.file, item.name,
1244 item.filename, item.headers)
1245 else:
1246 post[item.name] = item.value
1247 return post
1248
1249 @property
1250 def url(self):

Callers

nothing calls this directly

Calls 5

_get_body_stringMethod · 0.95
FormsDictClass · 0.85
_parse_qslFunction · 0.85
NCTextIOWrapperClass · 0.85
FileUploadClass · 0.85

Tested by

no test coverage detected