winazurestorageのフォーク
Révision | a48eeaf62ef9704d5ad99e9ed50682ca8e2af4d7 (tree) |
---|---|
l'heure | 2012-04-19 22:48:40 |
Auteur | hylom <hylom@hylo...> |
Commiter | hylom |
fix some minor bug for table storage and queue storage
@@ -19,6 +19,8 @@ from urllib import urlencode | ||
19 | 19 | from urlparse import urlsplit, parse_qs |
20 | 20 | from datetime import datetime, timedelta |
21 | 21 | |
22 | +import locale # dirty hack for locale changing | |
23 | + | |
22 | 24 | DEVSTORE_ACCOUNT = "devstoreaccount1" |
23 | 25 | DEVSTORE_SECRET_KEY = "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==" |
24 | 26 |
@@ -49,6 +51,9 @@ def parse_edm_datetime(input): | ||
49 | 51 | def parse_edm_int32(input): |
50 | 52 | return int(input) |
51 | 53 | |
54 | +def parse_edm_int64(input): | |
55 | + return long(input) | |
56 | + | |
52 | 57 | def parse_edm_double(input): |
53 | 58 | return float(input) |
54 | 59 |
@@ -66,26 +71,32 @@ class SharedKeyCredentials(object): | ||
66 | 71 | path = path[path.index('/'):] |
67 | 72 | |
68 | 73 | canonicalized_resource = "/" + self._account + path |
69 | - q = parse_qs(query) | |
70 | - if len(q.keys()) > 0: | |
71 | - canonicalized_resource +=''.join(["\n%s:%s" % (k, ','.join(sorted(q[k]))) for k in sorted(q.keys())]) | |
74 | + | |
75 | + if not for_tables: | |
76 | + q = parse_qs(query) | |
77 | + if len(q.keys()) > 0: | |
78 | + canonicalized_resource +=''.join(["\n%s:%s" % (k, ','.join(sorted(q[k]))) for k in sorted(q.keys())]) | |
72 | 79 | |
73 | 80 | if use_path_style_uris is None: |
74 | 81 | use_path_style_uris = re.match('^[\d.:]+$', host) is not None |
75 | 82 | |
76 | 83 | request.add_header(PREFIX_STORAGE_HEADER + 'version', '2011-08-18') |
84 | + locale.setlocale(locale.LC_ALL, "C") # dirty hack for locale changing | |
77 | 85 | request.add_header(PREFIX_STORAGE_HEADER + 'date', time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime())) #RFC 1123 |
86 | + | |
78 | 87 | if for_tables: |
79 | 88 | request.add_header('Date', request.get_header((PREFIX_STORAGE_HEADER + 'date').capitalize())) |
80 | 89 | request.add_header('DataServiceVersion', '1.0;NetFx') |
81 | 90 | request.add_header('MaxDataServiceVersion', '1.0;NetFx') |
91 | + | |
82 | 92 | canonicalized_headers = NEW_LINE.join(('%s:%s' % (k.lower(), request.get_header(k).strip()) for k in sorted(request.headers.keys(), lambda x,y: cmp(x.lower(), y.lower())) if k.lower().startswith(PREFIX_STORAGE_HEADER))) |
83 | 93 | |
84 | 94 | string_to_sign = request.get_method().upper() + NEW_LINE # verb |
85 | 95 | if not for_tables: |
86 | 96 | string_to_sign += (request.get_header('Content-encoding') or '') + NEW_LINE |
87 | 97 | string_to_sign += (request.get_header('Content-language') or '') + NEW_LINE |
88 | - string_to_sign += (request.get_header('Content-length') or '') + NEW_LINE | |
98 | + string_to_sign += str(request.get_header('Content-length') or '') + NEW_LINE | |
99 | + | |
89 | 100 | string_to_sign += (request.get_header('Content-md5') or '') + NEW_LINE |
90 | 101 | string_to_sign += (request.get_header('Content-type') or '') + NEW_LINE |
91 | 102 | string_to_sign += (request.get_header('Date') or '') + NEW_LINE |
@@ -272,6 +283,7 @@ class TableStorage(Storage): | ||
272 | 283 | t = property.getAttribute('m:type') |
273 | 284 | if t.lower() == 'edm.datetime': value = parse_edm_datetime(property.firstChild.data) |
274 | 285 | elif t.lower() == 'edm.int32': value = parse_edm_int32(property.firstChild.data) |
286 | + elif t.lower() == 'edm.int64': value = parse_edm_int64(property.firstChild.data) | |
275 | 287 | elif t.lower() == 'edm.boolean': value = parse_edm_boolean(property.firstChild.data) |
276 | 288 | elif t.lower() == 'edm.double': value = parse_edm_double(property.firstChild.data) |
277 | 289 | else: raise Exception(t.lower()) |
@@ -403,4 +415,4 @@ def main(): | ||
403 | 415 | pass |
404 | 416 | |
405 | 417 | if __name__ == '__main__': |
406 | - main() | |
\ No newline at end of file | ||
418 | + main() |