本文整理汇总了Python中utils.Data.append方法的典型用法代码示例。如果您正苦于以下问题:Python Data.append方法的具体用法?Python Data.append怎么用?Python Data.append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils.Data
的用法示例。
在下文中一共展示了Data.append方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: extractParam
# 需要导入模块: from utils import Data [as 别名]
# 或者: from utils.Data import append [as 别名]
def extractParam(self):
"""Turn muti part encoded form into params."""
params = []
try:
environ = {
'CONTENT_TYPE': self.headers['content-type'],
'CONTENT_LENGTH': self.headers['content-length'],
'REQUEST_METHOD': 'POST',
}
except KeyError:
trace('# Warning: missing header content-type or content-length'
' in file: %s not an http request ?\n' % self.file_path)
return params
form = FieldStorage(fp=StringIO(self.body),
environ=environ,
keep_blank_values=True)
try:
keys = form.keys()
except TypeError:
trace('# Using custom data for request: %s ' % self.file_path)
params = Data(self.headers['content-type'], self.body)
return params
for item in form.list:
key = item.name
value = item.value
filename = item.filename
if filename is None:
params.append([key, value])
else:
# got a file upload
filename = filename or ''
params.append([key, 'Upload("%s")' % filename])
if filename:
if os.path.exists(filename):
trace('# Warning: uploaded file: %s already'
' exists, keep it.\n' % filename)
else:
trace('# Saving uploaded file: %s\n' % filename)
f = open(filename, 'w')
f.write(str(value))
f.close()
return params