diff options
author | Ask Solem <askh@opera.com> | 2009-11-12 10:27:03 +0100 |
---|---|---|
committer | Ask Solem <askh@opera.com> | 2009-11-12 10:27:03 +0100 |
commit | 4bce9979704d8a21419a77356827259fa2caffb6 (patch) | |
tree | 360eddeda7a23752bb5962a21612ad95dbd48fb3 | |
parent | 664e5be33310e182751c9c6a1561f0b5317ebde6 (diff) | |
download | chishop-4bce9979704d8a21419a77356827259fa2caffb6.tar.bz2 chishop-4bce9979704d8a21419a77356827259fa2caffb6.tar.xz chishop-4bce9979704d8a21419a77356827259fa2caffb6.zip |
Revert brosners parse fix (didn't work properly yet, missing commits?)
-rw-r--r-- | djangopypi/views.py | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/djangopypi/views.py b/djangopypi/views.py index 5fc2fec..8817f66 100644 --- a/djangopypi/views.py +++ b/djangopypi/views.py | |||
@@ -31,9 +31,42 @@ ALREADY_EXISTS_FMT = _("""A file named "%s" already exists for %s. To fix """ | |||
31 | 31 | ||
32 | 32 | ||
33 | def parse_distutils_request(request): | 33 | def parse_distutils_request(request): |
34 | fp = StringIO(request.raw_post_data) | 34 | raw_post_data = request.raw_post_data |
35 | fs = cgi.FieldStorage(fp=fp, environ=request.META) | 35 | sep = raw_post_data.splitlines()[1] |
36 | return decode_fs(fs) | 36 | items = raw_post_data.split(sep) |
37 | post_data = {} | ||
38 | files = {} | ||
39 | for part in filter(lambda e: not e.isspace(), items): | ||
40 | item = part.splitlines() | ||
41 | if len(item) < 2: | ||
42 | continue | ||
43 | header = item[1].replace("Content-Disposition: form-data; ", "") | ||
44 | kvpairs = header.split(";") | ||
45 | headers = {} | ||
46 | for kvpair in kvpairs: | ||
47 | if not kvpair: | ||
48 | continue | ||
49 | key, value = kvpair.split("=") | ||
50 | headers[key] = value.strip('"') | ||
51 | if "name" not in headers: | ||
52 | continue | ||
53 | content = part[len("\n".join(item[0:2]))+2:len(part)-1] | ||
54 | if "filename" in headers: | ||
55 | file = SimpleUploadedFile(headers["filename"], content, | ||
56 | content_type="application/gzip") | ||
57 | files["distribution"] = [file] | ||
58 | elif headers["name"] in post_data: | ||
59 | post_data[headers["name"]].append(content) | ||
60 | else: | ||
61 | # Distutils sends UNKNOWN for empty fields (e.g platform) | ||
62 | # [russell.sim@gmail.com] | ||
63 | if content == 'UNKNOWN': | ||
64 | post_data[headers["name"]] = [None] | ||
65 | else: | ||
66 | post_data[headers["name"]] = [content] | ||
67 | |||
68 | return MultiValueDict(post_data), MultiValueDict(files) | ||
69 | |||
37 | 70 | ||
38 | 71 | ||
39 | def login_basic_auth(request): | 72 | def login_basic_auth(request): |