• R/O
  • HTTP
  • SSH
  • HTTPS

提交

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

winazurestorageのフォーク


Commit MetaInfo

修訂a48eeaf62ef9704d5ad99e9ed50682ca8e2af4d7 (tree)
時間2012-04-19 22:48:40
作者hylom <hylom@hylo...>
Commiterhylom

Log Message

fix some minor bug for table storage and queue storage

  • fix: fail authorization in some table storage api
  • fix: fail authorization in some queue storage api
  • TODO: fix generate invalid style date header when locale is not 'C'

Change Summary

差異

--- a/winazurestorage.py
+++ b/winazurestorage.py
@@ -19,6 +19,8 @@ from urllib import urlencode
1919 from urlparse import urlsplit, parse_qs
2020 from datetime import datetime, timedelta
2121
22+import locale # dirty hack for locale changing
23+
2224 DEVSTORE_ACCOUNT = "devstoreaccount1"
2325 DEVSTORE_SECRET_KEY = "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="
2426
@@ -49,6 +51,9 @@ def parse_edm_datetime(input):
4951 def parse_edm_int32(input):
5052 return int(input)
5153
54+def parse_edm_int64(input):
55+ return long(input)
56+
5257 def parse_edm_double(input):
5358 return float(input)
5459
@@ -66,26 +71,32 @@ class SharedKeyCredentials(object):
6671 path = path[path.index('/'):]
6772
6873 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())])
7279
7380 if use_path_style_uris is None:
7481 use_path_style_uris = re.match('^[\d.:]+$', host) is not None
7582
7683 request.add_header(PREFIX_STORAGE_HEADER + 'version', '2011-08-18')
84+ locale.setlocale(locale.LC_ALL, "C") # dirty hack for locale changing
7785 request.add_header(PREFIX_STORAGE_HEADER + 'date', time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime())) #RFC 1123
86+
7887 if for_tables:
7988 request.add_header('Date', request.get_header((PREFIX_STORAGE_HEADER + 'date').capitalize()))
8089 request.add_header('DataServiceVersion', '1.0;NetFx')
8190 request.add_header('MaxDataServiceVersion', '1.0;NetFx')
91+
8292 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)))
8393
8494 string_to_sign = request.get_method().upper() + NEW_LINE # verb
8595 if not for_tables:
8696 string_to_sign += (request.get_header('Content-encoding') or '') + NEW_LINE
8797 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+
89100 string_to_sign += (request.get_header('Content-md5') or '') + NEW_LINE
90101 string_to_sign += (request.get_header('Content-type') or '') + NEW_LINE
91102 string_to_sign += (request.get_header('Date') or '') + NEW_LINE
@@ -272,6 +283,7 @@ class TableStorage(Storage):
272283 t = property.getAttribute('m:type')
273284 if t.lower() == 'edm.datetime': value = parse_edm_datetime(property.firstChild.data)
274285 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)
275287 elif t.lower() == 'edm.boolean': value = parse_edm_boolean(property.firstChild.data)
276288 elif t.lower() == 'edm.double': value = parse_edm_double(property.firstChild.data)
277289 else: raise Exception(t.lower())
@@ -403,4 +415,4 @@ def main():
403415 pass
404416
405417 if __name__ == '__main__':
406- main()
\ No newline at end of file
418+ main()