Changeset - e861eb1c4a2f
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 15 years ago 2011-05-15 18:22:02
marcin@python-works.com
update caching_query from latest sqlalchemy
1 file changed with 4 insertions and 4 deletions:
0 comments (0 inline, 0 general)
rhodecode/model/caching_query.py
Show inline comments
 
@@ -104,15 +104,15 @@ class CachingQuery(Query):
 
        """Set the value in the cache for this query."""
 

	
 
        cache, cache_key = _get_cache_parameters(self)
 
        cache.put(cache_key, value)
 

	
 

	
 
def query_callable(manager):
 
def query_callable(manager, query_cls=CachingQuery):
 
    def query(*arg, **kw):
 
        return CachingQuery(manager, *arg, **kw)
 
        return query_cls(manager, *arg, **kw)
 
    return query
 

	
 

	
 
def get_cache_region(name, region):
 
    if region not in beaker.cache.cache_regions:
 
        raise BeakerException('Cache region `%s` not configured '
 
@@ -271,20 +271,20 @@ def _params_from_query(query):
 

	
 
    E.g. params_from_query(query.filter(Cls.foo==5).filter(Cls.bar==7)))
 
    would return [5, 7].
 

	
 
    """
 
    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()
 

	
 
        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
0 comments (0 inline, 0 general)