##// END OF EJS Templates
added version generation to pylons_app and showed it into template. Propagated baseController with some data for acces into each controller. Fixed simplehg middleware to get proper name of application
marcink -
r185:3380ca40 default
parent child Browse files
Show More
@@ -0,0 +1,13 b''
1 """
2 Hg app, a web based mercurial repository managment based on pylons
3 """
4
5 VERSION = (0, 6, 0, 'beta')
6
7 __version__ = '.'.join((str(each) for each in VERSION[:4]))
8
9 def get_version():
10 """
11 Returns shorter version (digit parts only) as string.
12 """
13 return '.'.join((str(each) for each in VERSION[:3]))
@@ -2,26 +2,35 b''
2 2
3 3 Provides the BaseController class for subclassing.
4 4 """
5 from beaker.cache import cache_region
6 from pylons import config, tmpl_context as c, request, session
5 7 from pylons.controllers import WSGIController
6 8 from pylons.templating import render_mako as render
9 from pylons_app.lib.auth import LoginRequired, AuthUser
10 from pylons_app.lib.utils import get_repo_slug
7 11 from pylons_app.model import meta
8 from beaker.cache import cache_region
9 from pylons import tmpl_context as c
10 12 from pylons_app.model.hg_model import HgModel
13 from pylons_app import get_version
11 14
12 15 @cache_region('long_term', 'cached_repo_list')
13 16 def _get_repos_cached():
14 17 return [rep for rep in HgModel().get_repos()]
15 18
16 19 class BaseController(WSGIController):
17
20
21 def __before__(self):
22 c.hg_app_version = get_version()
23 c.repos_prefix = config['hg_app_name']
24 c.repo_name = get_repo_slug(request)
25 c.hg_app_user = session.get('hg_app_user', AuthUser())
26 c.cached_repo_list = _get_repos_cached()
27 self.sa = meta.Session
28
18 29 def __call__(self, environ, start_response):
19 30 """Invoke the Controller"""
20 31 # WSGIController.__call__ dispatches to the Controller method
21 32 # the request is routed to. This routing information is
22 33 # available in environ['pylons.routes_dict']
23 c.cached_repo_list = _get_repos_cached()
24 self.sa = meta.Session
25 34 try:
26 35 return WSGIController.__call__(self, environ, start_response)
27 36 finally:
@@ -27,7 +27,7 b' class SimpleHg(object):'
27 27 self.application = application
28 28 self.config = config
29 29 #authenticate this mercurial request using
30 realm = '%s %s' % (config['repos_name'], 'mercurial repository')
30 realm = '%s %s' % (config['hg_app_name'], 'mercurial repository')
31 31 self.authenticate = AuthBasicAuthenticator(realm, authfunc)
32 32
33 33 def __call__(self, environ, start_response):
@@ -20,7 +20,7 b''
20 20 ${next.main()}
21 21 </div>
22 22 <div class="page-footer">
23 Mercurial App &copy; 2010
23 Hg App ${c.hg_app_version} &copy; 2010
24 24 </div>
25 25
26 26 <div id="powered-by">
@@ -1,3 +1,4 b''
1 from pylons_app import get_version
1 2 try:
2 3 from setuptools import setup, find_packages
3 4 except ImportError:
@@ -7,7 +8,7 b' except ImportError:'
7 8
8 9 setup(
9 10 name='pylons_app',
10 version='1.0',
11 version=get_version(),
11 12 description='',
12 13 author='marcin kuzminski',
13 14 author_email='marcin@python-blog.com',
General Comments 0
You need to be logged in to leave comments. Login now