##// END OF EJS Templates
Updated model with never vcs implementation using MercurialRepo class
Updated model with never vcs implementation using MercurialRepo class

File last commit:

r56:bf1b6404 default
r73:55d7f250 default
Show More
app_globals.py
77 lines | 2.6 KiB | text/x-python | PythonLexer
Marcin Kuzminski
initial commit.
r0 """The application's Globals object"""
Marcin Kuzminski
major app speedup moved the wsgi creation to app globals, in order to make it run only once....
r10 #uncomment the following if you want to serve a single repo
#from mercurial.hgweb.hgweb_mod import hgweb
from mercurial.hgweb.hgwebdir_mod import hgwebdir
Marcin Kuzminski
Added custom templates, did over check of code to make it work....
r20 from mercurial import templater
Marcin Kuzminski
major app speedup moved the wsgi creation to app globals, in order to make it run only once....
r10 from mercurial.hgweb.request import wsgiapplication
Marcin Kuzminski
Added custom templates, did over check of code to make it work....
r20 from mercurial import ui, config
import os
changed for pylons 0.1 / 1.0...
r43 from beaker.cache import CacheManager
from beaker.util import parse_cache_config_options
Marcin Kuzminski
initial commit.
r0 class Globals(object):
"""Globals acts as a container for objects available throughout the
life of the application
"""
changed for pylons 0.1 / 1.0...
r43 def __init__(self, config):
Marcin Kuzminski
initial commit.
r0 """One instance of Globals is created during application
initialization and is available during requests via the
'app_globals' variable
"""
Marcin Kuzminski
major app speedup moved the wsgi creation to app globals, in order to make it run only once....
r10 #two ways of building the merc app i don't know
#the fastest one but belive the wsgiapp is better
#self.hgapp = self.make_web_app()
changed for pylons 0.1 / 1.0...
r43 self.cache = CacheManager(**parse_cache_config_options(config))
Marcin Kuzminski
major app speedup moved the wsgi creation to app globals, in order to make it run only once....
r10 self.hgapp = wsgiapplication(self.make_web_app)
def make_web_app(self):
repos = "hgwebdir.config"
Marcin Kuzminski
Added custom templates, did over check of code to make it work....
r20 baseui = ui.ui()
cfg = config.config()
cfg.read(repos)
paths = cfg.items('paths')
Marcin Kuzminski
Implemented index page using vcs
r55 self.paths = paths
Marcin Kuzminski
Added custom templates, did over check of code to make it work....
r20 self.check_repo_dir(paths)
Marcin Kuzminski
Implemented index page using vcs
r55
Marcin Kuzminski
Added custom templates, did over check of code to make it work....
r20 self.set_statics(cfg)
for k, v in cfg.items('web'):
baseui.setconfig('web', k, v)
#magic trick to make our custom template dir working
templater.path.append(cfg.get('web', 'templates', None))
Marcin Kuzminski
Added last change translation to 'time ago', added generation of enabled zip archives
r56 self.baseui = baseui
Marcin Kuzminski
Tempalting change, bugfix for serving raw files, and diffs. Now raw files are not parsed thruough mako, and diffs are mako safe (not parsed also)
r31 #baseui.setconfig('web', 'description', '')
#baseui.setconfig('web', 'name', '')
#baseui.setconfig('web', 'contact', '')
#baseui.setconfig('web', 'allow_archive', '')
#baseui.setconfig('web', 'style', 'monoblue_plain')
#baseui.setconfig('web', 'baseurl', '')
#baseui.setconfig('web', 'staticurl', '')
hgwebapp = hgwebdir(paths, baseui=baseui)
Marcin Kuzminski
major app speedup moved the wsgi creation to app globals, in order to make it run only once....
r10 return hgwebapp
Marcin Kuzminski
Added custom templates, did over check of code to make it work....
r20
def set_statics(self, cfg):
'''
set's the statics for use in mako templates
@param cfg:
'''
self.statics = cfg.get('web', 'staticurl', '/static')
if not self.statics.endswith('/'):
self.statics += '/'
def check_repo_dir(self, paths):
repos_path = paths[0][1].split('/')
if repos_path[-1] in ['*', '**']:
repos_path = repos_path[:-1]
if repos_path[0] != '/':
repos_path[0] = '/'
if not os.path.isdir(os.path.join(*repos_path)):
raise Exception('Not a valid repository in %s' % paths[0][1])