mercurial/hgweb/hgwebdir_mod.py
changeset 4081 e6d26e71f049
parent 4051 022056263354
parent 4080 ef14fdb675da
child 4084 51e52db6b40d
--- a/mercurial/hgweb/hgwebdir_mod.py	Tue Jan 02 21:40:20 2007 -0800
+++ b/mercurial/hgweb/hgwebdir_mod.py	Tue Feb 13 10:25:45 2007 -0200
@@ -15,12 +15,13 @@
 
 # This is a stopgap
 class hgwebdir(object):
-    def __init__(self, config):
+    def __init__(self, config, parentui=None):
         def cleannames(items):
             return [(name.strip(os.sep), path) for name, path in items]
 
-        self.motd = ""
-        self.style = ""
+        self.parentui = parentui
+        self.motd = None
+        self.style = None
         self.repos_sorted = ('name', False)
         if isinstance(config, (list, tuple)):
             self.repos = cleannames(config)
@@ -73,13 +74,23 @@
             yield tmpl("footer", **map)
 
         def motd(**map):
-            yield self.motd
+            if self.motd is not None:
+                yield self.motd
+            else:
+                yield config('web', 'motd', '')
+
+        parentui = self.parentui or ui.ui(report_untrusted=False)
+
+        def config(section, name, default=None, untrusted=True):
+            return parentui.config(section, name, default, untrusted)
 
         url = req.env['REQUEST_URI'].split('?')[0]
         if not url.endswith('/'):
             url += '/'
 
         style = self.style
+        if style is None:
+            style = config('web', 'style', '')
         if req.form.has_key('style'):
             style = req.form['style'][0]
         mapfile = style_map(templater.templatepath(), style)
@@ -113,7 +124,7 @@
             rows = []
             parity = 0
             for name, path in self.repos:
-                u = ui.ui(report_untrusted=False)
+                u = ui.ui(parentui=parentui)
                 try:
                     u.readconfig(os.path.join(path, '.hg', 'hgrc'))
                 except IOError:
@@ -181,7 +192,8 @@
             if real:
                 req.env['REPO_NAME'] = virtual
                 try:
-                    hgweb(real).run_wsgi(req)
+                    repo = hg.repository(parentui, real)
+                    hgweb(repo).run_wsgi(req)
                 except IOError, inst:
                     req.write(tmpl("error", error=inst.strerror))
                 except hg.RepoError, inst: