##// 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,12 +2,15 b''
2
2
3 Provides the BaseController class for subclassing.
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 from pylons.controllers import WSGIController
7 from pylons.controllers import WSGIController
6 from pylons.templating import render_mako as render
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 from pylons_app.model import meta
11 from pylons_app.model import meta
8 from beaker.cache import cache_region
9 from pylons import tmpl_context as c
10 from pylons_app.model.hg_model import HgModel
12 from pylons_app.model.hg_model import HgModel
13 from pylons_app import get_version
11
14
12 @cache_region('long_term', 'cached_repo_list')
15 @cache_region('long_term', 'cached_repo_list')
13 def _get_repos_cached():
16 def _get_repos_cached():
@@ -15,13 +18,19 b' def _get_repos_cached():'
15
18
16 class BaseController(WSGIController):
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 def __call__(self, environ, start_response):
29 def __call__(self, environ, start_response):
19 """Invoke the Controller"""
30 """Invoke the Controller"""
20 # WSGIController.__call__ dispatches to the Controller method
31 # WSGIController.__call__ dispatches to the Controller method
21 # the request is routed to. This routing information is
32 # the request is routed to. This routing information is
22 # available in environ['pylons.routes_dict']
33 # available in environ['pylons.routes_dict']
23 c.cached_repo_list = _get_repos_cached()
24 self.sa = meta.Session
25 try:
34 try:
26 return WSGIController.__call__(self, environ, start_response)
35 return WSGIController.__call__(self, environ, start_response)
27 finally:
36 finally:
@@ -27,7 +27,7 b' class SimpleHg(object):'
27 self.application = application
27 self.application = application
28 self.config = config
28 self.config = config
29 #authenticate this mercurial request using
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 self.authenticate = AuthBasicAuthenticator(realm, authfunc)
31 self.authenticate = AuthBasicAuthenticator(realm, authfunc)
32
32
33 def __call__(self, environ, start_response):
33 def __call__(self, environ, start_response):
@@ -20,7 +20,7 b''
20 ${next.main()}
20 ${next.main()}
21 </div>
21 </div>
22 <div class="page-footer">
22 <div class="page-footer">
23 Mercurial App &copy; 2010
23 Hg App ${c.hg_app_version} &copy; 2010
24 </div>
24 </div>
25
25
26 <div id="powered-by">
26 <div id="powered-by">
@@ -1,3 +1,4 b''
1 from pylons_app import get_version
1 try:
2 try:
2 from setuptools import setup, find_packages
3 from setuptools import setup, find_packages
3 except ImportError:
4 except ImportError:
@@ -7,7 +8,7 b' except ImportError:'
7
8
8 setup(
9 setup(
9 name='pylons_app',
10 name='pylons_app',
10 version='1.0',
11 version=get_version(),
11 description='',
12 description='',
12 author='marcin kuzminski',
13 author='marcin kuzminski',
13 author_email='marcin@python-blog.com',
14 author_email='marcin@python-blog.com',
General Comments 0
You need to be logged in to leave comments. Login now