diff --git a/rhodecode/controllers/home.py b/rhodecode/controllers/home.py --- a/rhodecode/controllers/home.py +++ b/rhodecode/controllers/home.py @@ -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') diff --git a/rhodecode/lib/caching_query.py b/rhodecode/lib/caching_query.py --- a/rhodecode/lib/caching_query.py +++ b/rhodecode/lib/caching_query.py @@ -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 diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -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