-
Notifications
You must be signed in to change notification settings - Fork 0
/
appengine_config.py
48 lines (48 loc) · 1.46 KB
/
appengine_config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# import base64
# import quopri
#
# from webob import multidict
#
# # Patch to fix a problem with encoding of fields in blobstore upload forms.
# # See http://code.google.com/p/googleappengine/issues/detail?id=2749
#
# def from_fieldstorage(cls, fs):
# """
# Create a dict from a cgi.FieldStorage instance
# """
# obj = cls()
# if fs.list:
# # fs.list can be None when there's nothing to parse
# for field in fs.list:
# if field.filename:
# obj.add(field.name, field)
# else:
#
# # first, set a common charset to utf-8.
# common_charset = 'utf-8'
#
# # second, check Content-Transfer-Encoding and decode
# # the value appropriately
# field_value = field.value
# transfer_encoding = field.headers.get(
# 'Content-Transfer-Encoding', None)
#
# if transfer_encoding == 'base64':
# field_value = base64.b64decode(field_value)
#
# if transfer_encoding == 'quoted-printable':
# field_value = quopri.decodestring(field_value)
#
# if field.type_options.has_key('charset') and \
# field.type_options['charset'] != common_charset:
# # decode with a charset specified in each
# # multipart, and then encode it again with a
# # charset specified in top level FieldStorage
# field_value = field_value.decode(
# field.type_options['charset']).encode(common_charset)
#
# obj.add(field.name, field_value)
#
# return obj
#
# multidict.MultiDict.from_fieldstorage = classmethod(from_fieldstorage)