diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-12-22 11:37:07 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-12-22 11:37:07 -0500 |
commit | 993af53204a0e4378fbf65a0bbf9a617e34dede1 (patch) | |
tree | 163546f1cfbed3c78fd2700920db32e44ac12671 | |
parent | 78d6c7c62e0cd87c4075985708c77f68a1373f43 (diff) | |
download | sqlalchemy-993af53204a0e4378fbf65a0bbf9a617e34dede1.tar.gz |
- fix beaker caching example to use new ".callable" param on bind
-rw-r--r-- | examples/beaker_caching/caching_query.py | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/examples/beaker_caching/caching_query.py b/examples/beaker_caching/caching_query.py index a94eea6ac..d9ec1576e 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}) |