diff --git a/pylons_app/__init__.py b/pylons_app/__init__.py --- a/pylons_app/__init__.py +++ b/pylons_app/__init__.py @@ -0,0 +1,13 @@ +""" +Hg app, a web based mercurial repository managment based on pylons +""" + +VERSION = (0, 6, 0, 'beta') + +__version__ = '.'.join((str(each) for each in VERSION[:4])) + +def get_version(): + """ + Returns shorter version (digit parts only) as string. + """ + return '.'.join((str(each) for each in VERSION[:3])) diff --git a/pylons_app/lib/base.py b/pylons_app/lib/base.py --- a/pylons_app/lib/base.py +++ b/pylons_app/lib/base.py @@ -2,26 +2,35 @@ Provides the BaseController class for subclassing. """ +from beaker.cache import cache_region +from pylons import config, tmpl_context as c, request, session from pylons.controllers import WSGIController from pylons.templating import render_mako as render +from pylons_app.lib.auth import LoginRequired, AuthUser +from pylons_app.lib.utils import get_repo_slug from pylons_app.model import meta -from beaker.cache import cache_region -from pylons import tmpl_context as c from pylons_app.model.hg_model import HgModel +from pylons_app import get_version @cache_region('long_term', 'cached_repo_list') def _get_repos_cached(): return [rep for rep in HgModel().get_repos()] class BaseController(WSGIController): - + + def __before__(self): + c.hg_app_version = get_version() + c.repos_prefix = config['hg_app_name'] + c.repo_name = get_repo_slug(request) + c.hg_app_user = session.get('hg_app_user', AuthUser()) + c.cached_repo_list = _get_repos_cached() + self.sa = meta.Session + def __call__(self, environ, start_response): """Invoke the Controller""" # WSGIController.__call__ dispatches to the Controller method # the request is routed to. This routing information is # available in environ['pylons.routes_dict'] - c.cached_repo_list = _get_repos_cached() - self.sa = meta.Session try: return WSGIController.__call__(self, environ, start_response) finally: diff --git a/pylons_app/lib/simplehg.py b/pylons_app/lib/simplehg.py --- a/pylons_app/lib/simplehg.py +++ b/pylons_app/lib/simplehg.py @@ -27,7 +27,7 @@ class SimpleHg(object): self.application = application self.config = config #authenticate this mercurial request using - realm = '%s %s' % (config['repos_name'], 'mercurial repository') + realm = '%s %s' % (config['hg_app_name'], 'mercurial repository') self.authenticate = AuthBasicAuthenticator(realm, authfunc) def __call__(self, environ, start_response): diff --git a/pylons_app/templates/base/base.html b/pylons_app/templates/base/base.html --- a/pylons_app/templates/base/base.html +++ b/pylons_app/templates/base/base.html @@ -20,7 +20,7 @@ ${next.main()}