The unified diff between revisions [52c07981..] and [9e7f3ce1..] is displayed below. It can also be downloaded as a raw diff.
#
#
# patch "handlers.py"
# from [e9af5798e92963ad207ab1c3a3646818ae952175]
# to [f5978ee498a2bce37a15bdc0e509e8bb56609e33]
#
# patch "render.py"
# from [2a55c2e22ff97d808ca4fd06d39eb7bea8a101d3]
# to [b93fcb701c8361ee69bdffaf507de225768315b0]
#
# patch "templates/base.html"
# from [8d1f9004c63ca950378f4dc1425deee063b0216d]
# to [47574ccfc9aff518749857eb878ba93c8f2e9f48]
#
# patch "viewmtn.py"
# from [ae38f0301e147803284029b0216e4c0c4e5fd6bb]
# to [c5366d46df9e87de6c4357412799dc5220e3a0cc]
#
============================================================
--- handlers.py e9af5798e92963ad207ab1c3a3646818ae952175
+++ handlers.py f5978ee498a2bce37a15bdc0e509e8bb56609e33
@@ -37,16 +37,13 @@ else:
else:
mimeicon = None
-# Figure out branch divisions
-divisions = branchdiv.BranchDivisions ()
-
class Index(object):
def GET(self, ctxt):
branches = list(ctxt.ops.branches ())
- divisions.calculate_divisions (branches)
+ ctxt.branchdivs.calculate_divisions (branches)
def division_iter():
bitter = iter(branches)
- divs = divisions.divisions
+ divs = ctxt.branchdivs.divisions
n_divs = len(divs)
in_divs = {}
look_for = 0
============================================================
--- render.py 2a55c2e22ff97d808ca4fd06d39eb7bea8a101d3
+++ render.py b93fcb701c8361ee69bdffaf507de225768315b0
@@ -133,7 +133,7 @@ class Renderer(object):
class Renderer(object):
- def __init__(self):
+ def __init__(self, **kwargs):
# any templates that can be inherited from, should be added to the list here
self.templates = [ ('base.html', 'base'),
('revision.html', 'revision'),
@@ -149,6 +149,7 @@ class Renderer(object):
'static_uri_path' : config.static_uri_path,
'version' : release.version,
}
+ self.terms.update(kwargs)
def load_templates(self):
if self._templates_loaded: return
============================================================
--- templates/base.html 8d1f9004c63ca950378f4dc1425deee063b0216d
+++ templates/base.html 47574ccfc9aff518749857eb878ba93c8f2e9f48
@@ -16,7 +16,11 @@
<div id="popupBox" class="invisible"></div>
<div id="menuBar">
- <strong>ViewMTN</strong>:
+ <strong>ViewMTN
+#if $have_multidb
+— $dbdescr
+#end if
+:</strong>
<a href="$perdb_join('')">Branches</a> |
<a href="$perdb_join('tags')">Tags</a> |
<a href="$perdb_join('help')">Help</a> |
============================================================
--- viewmtn.py ae38f0301e147803284029b0216e4c0c4e5fd6bb
+++ viewmtn.py c5366d46df9e87de6c4357412799dc5220e3a0cc
@@ -13,7 +13,7 @@ import web
from itertools import izip, chain, repeat
from urlparse import urljoin
import web
-import mtn, handlers, links
+import mtn, handlers, links, branchdiv
from urls import common_urls, perdb_urls
from render import Renderer
import config
@@ -24,11 +24,13 @@ class RequestContext(object):
return izip(*[chain(iterable, repeat(padvalue, n-1))]*n)
class RequestContext(object):
- def __init__ (self, dbname, ops, renderer):
- self.dbname, self.ops, self.renderer = dbname, ops, renderer
+ def __init__ (self, **kwargs):
+ for k in kwargs:
+ setattr(self, k, kwargs[k])
+ self.render_attrs = kwargs.keys()
# make sure that any unread automate output is flushed away
- if not ops is None:
- ops.per_request()
+ if not self.ops is None:
+ self.ops.per_request()
self.nodb_join = lambda path: urljoin(config.dynamic_uri_path, path)
if self.dbname is None:
self.perdb_join = self.nodb_join
@@ -41,39 +43,52 @@ class RequestContext(object):
return links.link (*args, **kwargs)
def render(self, *args, **kwargs):
+ for attr in self.render_attrs:
+ kwargs[attr] = getattr(self, attr)
self.renderer.render (self, *args, **kwargs)
class RequestContextFactory(object):
def __init__ (self):
- # has the user specified a dbfiles hash? if so, use it
- self.ops_instances = {}
+ self.dbstore = { 'ops' : {}, 'branchdivs' : {}, 'dbdescr' : {}}
self.default = None
- self.renderer = Renderer()
+ # has the user specified a dbfiles hash? if so, use it
if hasattr (config, "dbfiles"):
- for name in config.dbfiles:
- self.ops_instances[name] = mtn.Operations([config.monotone, config.dbfiles[name]])
+ for name, dbfile, description in grouper(3, config.dbfiles):
+ self.add_to_store(name, ops=mtn.Operations([config.monotone, dbfile]),
+ branchdivs=branchdiv.BranchDivisions(),
+ dbdescr=description)
if hasattr (config, "defaultdb"):
self.default = config.defaultdb
+ have_multidb = True
else:
- self.ops_instances[None] = mtn.Operations([config.monotone, config.dbfile])
+ self.add_to_store(None, ops=mtn.Operations([config.monotone, config.dbfile]),
+ branchdivs=branchdiv.BranchDivisions(),
+ dbdescr="")
self.default = None
-
+ have_multidb = False
+ self.renderer = Renderer(have_multidb=have_multidb)
+
+ def add_to_store(self, name, **kwargs):
+ for k in kwargs:
+ self.dbstore[k][name] = kwargs[k]
+
+ def get_from_store(self, k, name, default=None):
+ return self.dbstore[k].get(name, default)
+
def __getitem__(self, name):
if name is None:
- ops = self.ops_instances.get (self.default, None)
- else:
- ops = self.ops_instances.get (name, None)
+ name = self.default
+ ops = self.get_from_store("ops", name)
if ops is None:
return None
else:
- return RequestContext(name, ops, self.renderer)
+ dbdescr = self.get_from_store("dbdescr", name)
+ branchdivs = self.get_from_store("branchdivs", name)
+ return RequestContext(dbname=name, ops=ops, dbdescr=dbdescr, branchdivs=branchdivs, renderer=self.renderer)
def runfcgi_apache(func):
web.wsgi.runfcgi(func, None)
-def per_request_wrapper(func, *args, **kwargs):
- return func(*args, **kwargs)
-
if __name__ == '__main__':
if hasattr(config, "running_under_apache2") and config.running_under_apache2:
web.wsgi.runwsgi = runfcgi_apache
@@ -118,8 +133,7 @@ if __name__ == '__main__':
return urls, fvars
urls, fvars = assemble_urls()
- func = lambda : per_request_wrapper(web.webpyfunc(urls, fvars=fvars))
- web.run(func, globals())
+ web.run(urls, fvars)
###
### vi:expandtab:sw=4:ts=4