def application(environ, response):
s = str(environ['wsgi.input'].read())
b = compile('boundary=(.*)').search(environ['CONTENT_TYPE']).group
(1)
p = compile(r'.*Content-Type: application/octet-stream\\r\\n\\r\\n
(.*)\\r\\n--'+b+'.*'+b+'--', DOTALL).match(s).group(1)
db.execute('UPDATE users SET picture=? WHERE uid=?',
(p,session.UID))
(a) don't write obfuscatory code :-0
E.g.
(1) re.compile(pattern).search(data) -> re.search(pattern, data)
(2) re.compile(pattern).match(data) -> re.match(pattern, data)
(3) re.match('.*blahblah', data) -> re.search('blahblah', data)
(b) don't use re when ordinary str or bytes methods will do
E.g. instead of:
b = re.search('boundary=(.*)'), environ['CONTENT_TYPE']).group(1)
try
b = environ['CONTENT_TYPE'].split('boundary=')[1]
(c) Is that code meant to be rough pseudocode to illustrate what you
are trying to do, or is it meant to be working code? If the latter:
* Do you have this working in 2.X?
yep
* Are you sure the pattern to retrieve the picture is correct?