From 993af53204a0e4378fbf65a0bbf9a617e34dede1 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 22 Dec 2010 11:37:07 -0500 Subject: [PATCH] - fix beaker caching example to use new ".callable" param on bind --- examples/beaker_caching/caching_query.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/examples/beaker_caching/caching_query.py b/examples/beaker_caching/caching_query.py index a94eea6ac2..d9ec1576eb 100644 --- a/examples/beaker_caching/caching_query.py +++ b/examples/beaker_caching/caching_query.py @@ -118,12 +118,14 @@ def _get_cache_parameters(query): region, namespace, cache_key = query._cache_parameters namespace = _namespace_from_query(namespace, query) - + 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]) - + + assert cache_key is not None, "Cache key was None !" + # get cache cache = query.cache_manager.get_cache_region(namespace, region) @@ -253,14 +255,17 @@ def _params_from_query(query): """ 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}) -- 2.47.2