Changeset 315708 in indico for indico/web/http_api/cache.py


Ignore:
Timestamp:
08/23/11 15:38:51 (21 months ago)
Author:
Jose Benito <jose.benito.gonzalez@…>
Branches:
master, hello-world-walkthrough, ipv6, v0.98-series, v0.98.2, v0.98.3, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, 0da0c1403bae8e51d8229f460181c71b9e6dda72
Children:
fcdc60
Parents:
1ea4c5
git-author:
Adrian Moennich <jerome.ernst.monnich@…> (05/12/11 14:06:08)
git-committer:
Jose Benito <jose.benito.gonzalez@…> (08/23/11 15:38:51)
Message:

[IMP] Improve URL format for caching/signing

  • in both cases the query strign is sorted
  • the signature is now passed via &signature=...
  • the timestamp is included as &timestamp=...
  • the cache key now uses SHA-256 instead of hash()
File:
1 edited

Legend:

Unmodified
Added
Removed
  • indico/web/http_api/cache.py

    r9b51c4 r315708  
    2020from MaKaC.common.cache import MultiLevelCacheEntry, MultiLevelCache 
    2121import datetime 
     22import hashlib 
    2223import time 
    2324import os 
     
    5152        return ['requests'] 
    5253 
    53     def _generateKey(self, path, qdata): 
    54         queryHash = hash(frozenset((key, frozenset(values)) for key, values in qdata.iteritems())) 
    55         return '.'.join(map(str, (hash(path), queryHash))) 
     54    def cacheObject(self, key, obj): 
     55        key = hashlib.sha256(key).hexdigest() 
     56        return super(RequestCache, self).cacheObject(key, obj) 
    5657 
    57     def cacheObject(self, path, qdata, obj): 
    58         return super(RequestCache, self).cacheObject(self._generateKey(path, qdata), obj) 
    59  
    60     def loadObject(self, path, qdata): 
    61         return super(RequestCache, self).loadObject(self._generateKey(path, qdata)) 
     58    def loadObject(self, key): 
     59        key = hashlib.sha256(key).hexdigest() 
     60        return super(RequestCache, self).loadObject(key) 
    6261 
    6362    def isDirty(self, path, object): 
Note: See TracChangeset for help on using the changeset viewer.