Changeset - 8e9f51091229
[Not reviewed]
beta
0 3 0
Marcin Kuzminski - 14 years ago 2011-11-26 02:01:08
marcin@python-works.com
fixed caching query on repos path
- small fixes to caching query
3 files changed with 21 insertions and 10 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/home.py
Show inline comments
 
@@ -45,7 +45,8 @@ class HomeController(BaseController):
 

	
 
        c.repos_list = self.scm_model.get_repos()
 

	
 
        c.groups = RepoGroup.query().filter(RepoGroup.group_parent_id == None).all()
 
        c.groups = RepoGroup.query()\
 
            .filter(RepoGroup.group_parent_id == None).all()
 

	
 
        return render('/index.html')
 

	
rhodecode/lib/caching_query.py
Show inline comments
 
@@ -137,8 +137,13 @@ def _get_cache_parameters(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])
 
        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 @@ 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})
 
    for f in query._from_obj:
 
        visitors.traverse(f, {}, {'bindparam':visit_bindparam})
 
    return v
rhodecode/model/db.py
Show inline comments
 
@@ -573,7 +573,7 @@ class Repository(Base, BaseModel):
 
        """
 
        q = Session().query(RhodeCodeUi).filter(RhodeCodeUi.ui_key ==
 
                                              Repository.url_sep())
 
        q.options(FromCache("sql_cache_short", "repository_repo_path"))
 
        q = q.options(FromCache("sql_cache_short", "repository_repo_path"))
 
        return q.one().ui_value
 

	
 
    @property
0 comments (0 inline, 0 general)