Member since Oct 25, 2009, follows 0 people, 0 public groups, 879 public bookmarks (886 total).
More »
Tags
| Recent Tags: | |
|---|---|
| Top Tags: |
More »
Recent Bookmarks and Annotations
- WordPress › WP-Cumulus « WordPress Plugins on 2009-11-22
-
Blog Entry: PyAWS - Adding Request Authentication on 2009-11-21
-
def buildRequest(argv):
"""Build the REST request URL from argv,
all key, value pairs in argv are quoted."""
url = "https://" + __supportedLocales[getLocale()] + "/onca/xml?"
argv['Service'] = 'AWSECommerceService' #add Service to url param to argv so it canbe sorted
argv['Timestamp'] = strftime("%Y-%m-%dT%H:%M:%SZ", gmtime()) # add GMT Timestamp url param to argv, this is required when using a signature
sortedArgv = argv.items()
sortedArgv.sort() #args must be sorted so both you and amazon generate the same hashed signature
args = '&'.join(['%s=%s' % (k,urllib.quote(str(v))) for (k,v) in sortedArgv if v])
paramsToEncode = '&'.join(['%s=%s' % (k,urllib.quote(str(v))) for (k,v) in sortedArgv if v])
stringToSign = "GET"+"\n"+__supportedLocales[getLocale()]+"\n"+"/onca/xml"+"\n"+paramsToEncode.encode('utf-8')
signature = urllib.quote(base64.b64encode(hmac.new(getSecretKey(), stringToSign, hashlib.sha256).digest()))
return url + '&'.join(['%s=%s' % (k,urllib.quote(str(v))) for (k,v) in sortedArgv if v])+"&Signature="+signature -
1) I'd like to add some minor change - the parameters must be encoded accordingly to RFC 3986 (http://tools.ietf.org/html/rfc3986)
as stated in here: http://docs.amazonwebservices.com/AWS...So, i changed urllib.quote() to this function:
----------------------------------------------------------------------------------
rfc_safe = "-._~"# encodes string accordingly to RFC 3986 (do not encode unreserved characters)
def strToRFC(s):
return urllib.quote(s, safe = rfc_safe)
---------------------------------------------------------------------------------- - 1 more annotations...
-
- Digg Style Pagination In Django Revisited | Django Aware on 2009-11-21
- 24 JavaScript Best Practices for Beginners – Basix - Nettuts+ on 2009-11-21
- fring on Android on 2009-11-20
- Django snippets: Build tags files for emacs and vim on 2009-11-20
- The Bone Church Playboy - Stephen King Poem - Stephen King's The Bone Church Poem for Playboy Magazine on 2009-11-19
- Django snippets: Git media cache busting tag on 2009-11-19
- Django snippets: ExtendibleAdmin class on 2009-11-18
- TED Blog: Science-inspired design: Mathieu Lehanneur on TED.com on 2009-11-18
Diigo is about better ways to research, share and collaborate on information. Learn more »
Join Diigo