# HG changeset patch # User Marcin Kuzminski # Date 2010-11-28 04:26:26 # Node ID 30d3161c66836766a358748d3df52a6073623803 # Parent 71113f64b2d828b7131896c64fec3e9a5afc877b Implemented fancier top menu for logged and anonymous users little error fix for cached query diff --git a/rhodecode/lib/base.py b/rhodecode/lib/base.py --- a/rhodecode/lib/base.py +++ b/rhodecode/lib/base.py @@ -21,10 +21,12 @@ class BaseController(WSGIController): c.cached_repo_list = ScmModel().get_repos() c.backends = BACKENDS.keys() + self.sa = meta.Session() + scm_model = ScmModel(self.sa) + #c.unread_journal = scm_model.get_unread_journal() + if c.repo_name: - scm_model = ScmModel() cached_repo = scm_model.get(c.repo_name) - if cached_repo: c.repository_tags = cached_repo.tags c.repository_branches = cached_repo.branches @@ -36,7 +38,6 @@ class BaseController(WSGIController): c.repository_followers = 0 c.repository_forks = 0 - self.sa = meta.Session() def __call__(self, environ, start_response): """Invoke the Controller""" diff --git a/rhodecode/model/caching_query.py b/rhodecode/model/caching_query.py --- a/rhodecode/model/caching_query.py +++ b/rhodecode/model/caching_query.py @@ -55,11 +55,11 @@ class CachingQuery(Query): the "public" method of configuring this state upon the CachingQuery. """ - + def __init__(self, manager, *args, **kw): self.cache_manager = manager Query.__init__(self, *args, **kw) - + def __iter__(self): """override __iter__ to pull results from Beaker if particular attributes have been configured. @@ -101,7 +101,7 @@ class CachingQuery(Query): """Set the value in the cache for this query.""" cache, cache_key = _get_cache_parameters(self) - cache.put(cache_key, value) + cache.put(cache_key, value) def query_callable(manager): def query(*arg, **kw): @@ -110,11 +110,11 @@ def query_callable(manager): def get_cache_region(name, region): if region not in beaker.cache.cache_regions: - raise BeakerException('Cache region not configured: %s' + raise BeakerException('Cache region `%s` not configured ' 'Check if proper cache settings are in the .ini files' % region) kw = beaker.cache.cache_regions[region] return beaker.cache.Cache._get_cache(name, kw) - + def _get_cache_parameters(query): """For a query with cache_region and cache_namespace configured, return the correspoinding Cache instance and cache key, based @@ -125,7 +125,7 @@ def _get_cache_parameters(query): raise ValueError("This Query does not have caching parameters configured.") region, namespace, cache_key = query._cache_parameters - + namespace = _namespace_from_query(namespace, query) if cache_key is None: @@ -153,15 +153,15 @@ def _namespace_from_query(namespace, que return namespace def _set_cache_parameters(query, region, namespace, cache_key): - + if hasattr(query, '_cache_parameters'): region, namespace, cache_key = query._cache_parameters raise ValueError("This query is already configured " - "for region %r namespace %r" % + "for region %r namespace %r" % (region, namespace) ) query._cache_parameters = region, namespace, cache_key - + class FromCache(MapperOption): """Specifies that a Query should load results from a cache.""" @@ -187,10 +187,10 @@ class FromCache(MapperOption): self.region = region self.namespace = namespace self.cache_key = cache_key - + def process_query(self, query): """Process a Query during normal loading operation.""" - + _set_cache_parameters(query, self.region, self.namespace, self.cache_key) class RelationshipCache(MapperOption): @@ -263,13 +263,13 @@ 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() - + v.append(value) if query._criterion is not None: visitors.traverse(query._criterion, {}, {'bindparam':visit_bindparam}) diff --git a/rhodecode/model/scm.py b/rhodecode/model/scm.py --- a/rhodecode/model/scm.py +++ b/rhodecode/model/scm.py @@ -46,7 +46,7 @@ from rhodecode.model import BaseModel from rhodecode.model.user import UserModel from rhodecode.model.db import Repository, RhodeCodeUi, CacheInvalidation, \ - UserFollowing + UserFollowing, UserLog from rhodecode.model.caching_query import FromCache from sqlalchemy.orm import joinedload @@ -333,6 +333,11 @@ class ScmModel(BaseModel): return self.sa.query(Repository)\ .filter(Repository.fork_id == repo_id).count() + + def get_unread_journal(self): + return self.sa.query(UserLog).count() + + def _should_invalidate(self, repo_name): """ Looks up database for invalidation signals for this repo_name diff --git a/rhodecode/public/css/style.css b/rhodecode/public/css/style.css --- a/rhodecode/public/css/style.css +++ b/rhodecode/public/css/style.css @@ -190,18 +190,32 @@ margin:0; padding:0 30px; } + +#header ul#logged-user{ +margin-bottom:5px !important; +-webkit-border-radius: 0px 0px 8px 8px; +-khtml-border-radius: 0px 0px 8px 8px; +-moz-border-radius: 0px 0px 8px 8px; +border-radius: 0px 0px 8px 8px; +height:37px; +background:url("../images/header_inner.png") repeat-x scroll 0 0 #003367 +} + #header ul#logged-user li { list-style:none; float:left; -border-left:1px solid #bbb; -border-right:1px solid #a5a5a5; -margin:-2px 0 0; -padding:10px 12px; +margin:8px 0 0; +padding:4px 12px; +border-left: 1px solid #316293; } #header ul#logged-user li.first { border-left:none; -margin:-6px; +margin:4px; +} + +#header ul#logged-user li.first div.gravatar { +margin-top:-2px; } #header ul#logged-user li.first div.account { @@ -214,13 +228,12 @@ border-right:none; } #header ul#logged-user li a { -color:#4e4e4e; +color:#fff; font-weight:700; text-decoration:none; } #header ul#logged-user li a:hover { -color:#376ea6; text-decoration:underline; } @@ -229,7 +242,7 @@ color:#fff; } #header ul#logged-user li.highlight a:hover { -color:#376ea6; +color:#FFF; } #header #header-inner { diff --git a/rhodecode/templates/base/base.html b/rhodecode/templates/base/base.html --- a/rhodecode/templates/base/base.html +++ b/rhodecode/templates/base/base.html @@ -16,26 +16,34 @@