Mercurial > kallithea
diff rhodecode/lib/caching_query.py @ 1727:8e9f51091229 beta
fixed caching query on repos path
- small fixes to caching query
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sat, 26 Nov 2011 03:01:08 +0200 |
parents | f522f4d3bf93 |
children | bf8ed0adbc66 |
line wrap: on
line diff
--- a/rhodecode/lib/caching_query.py Sat Nov 26 02:23:28 2011 +0200 +++ b/rhodecode/lib/caching_query.py Sat Nov 26 03:01:08 2011 +0200 @@ -137,8 +137,13 @@ if cache_key is None: # cache key - the value arguments from this query's parameters. - args = _params_from_query(query) - cache_key = " ".join([str(x) for x in args]) + args = [str(x) for x in _params_from_query(query)] + args.extend(filter(lambda k:k not in ['None', None, u'None'], + [str(query._limit), str(query._offset)])) + cache_key = " ".join(args) + + if cache_key is None: + raise Exception('Cache key cannot be None') # get cache #cache = query.cache_manager.get_cache_region(namespace, region) @@ -275,15 +280,20 @@ """ v = [] def visit_bindparam(bind): - value = query._params.get(bind.key, bind.value) - # lazyloader may dig a callable in here, intended - # to late-evaluate params after autoflush is called. - # convert to a scalar value. - if callable(value): - value = value() + if bind.key in query._params: + value = query._params[bind.key] + elif bind.callable: + # lazyloader may dig a callable in here, intended + # to late-evaluate params after autoflush is called. + # convert to a scalar value. + value = bind.callable() + else: + value = bind.value v.append(value) if query._criterion is not None: visitors.traverse(query._criterion, {}, {'bindparam':visit_bindparam}) + for f in query._from_obj: + visitors.traverse(f, {}, {'bindparam':visit_bindparam}) return v