yield old.key # openlibrary.utils can't be imported directly because # openlibrary.plugins.openlibrary masks openlibrary module olmemcache = __import__('openlibrary.utils.olmemcache', None, None, ['x']) def MemcachedDict(servers=None): servers = servers or [] """Cache implementation with OL customized memcache client.""" client = olmemcache.Client(servers) return cache.MemcachedDict(memcache_client=client) cache.register_cache('memcache', MemcachedDict) def _process_key(key): mapping = ('/l/', '/languages/', '/a/', '/authors/', '/b/', '/books/', '/user/', '/people/') for old, new in web.group(mapping, 2): if key.startswith(old): return new + key[len(old):] return key def _process_data(data): if isinstance(data, list): return [_process_data(d) for d in data] elif isinstance(data, dict):
if 'author' in a and 'key' in a['author']: yield a['author']['key'] def invalidate_default(self, site, old): yield old.key # openlibrary.utils can't be imported directly because # openlibrary.plugins.openlibrary masks openlibrary module olmemcache = __import__("openlibrary.utils.olmemcache", None, None, ['x']) def MemcachedDict(servers=[]): """Cache implementation with OL customized memcache client.""" client = olmemcache.Client(servers) return cache.MemcachedDict(memcache_client=client) cache.register_cache('memcache', MemcachedDict) def _process_key(key): mapping = ( "/l/", "/languages/", "/a/", "/authors/", "/b/", "/books/", "/user/", "/people/" ) for old, new in web.group(mapping, 2): if key.startswith(old): return new + key[len(old):] return key def _process_data(data): if isinstance(data, list):
def invalidate_default(self, site, old): yield old.key # openlibrary.utils can't be imported directly because # openlibrary.plugins.openlibrary masks openlibrary module olmemcache = __import__("openlibrary.utils.olmemcache", None, None, ["x"]) def MemcachedDict(servers=[]): """Cache implementation with OL customized memcache client.""" client = olmemcache.Client(servers) return cache.MemcachedDict(memcache_client=client) cache.register_cache("memcache", MemcachedDict) def _process_key(key): mapping = ("/l/", "/languages/", "/a/", "/authors/", "/b/", "/books/", "/user/", "/people/") for old, new in web.group(mapping, 2): if key.startswith(old): return new + key[len(old) :] return key def _process_data(data): if isinstance(data, list): return [_process_data(d) for d in data] elif isinstance(data, dict): if "key" in data: