[Buildbot-commits] buildbot/buildbot/status/web base.py, 1.2, 1.3 baseweb.py, 1.6, 1.7 logs.py, 1.2, 1.3

Brian Warner warner at users.sourceforge.net
Wed Aug 1 22:08:49 UTC 2007


Update of /cvsroot/buildbot/buildbot/buildbot/status/web
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv29300/buildbot/status/web

Modified Files:
	base.py baseweb.py logs.py 
Log Message:
[project @ web-refactoring: improve templatability]

Original author: warner at lothar.com
Date: 2007-08-01 00:16:02+00:00

Index: base.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/web/base.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- base.py	1 Aug 2007 22:08:26 -0000	1.2
+++ base.py	1 Aug 2007 22:08:47 -0000	1.3
@@ -155,7 +155,9 @@
     def fillTemplate(self, template, request):
         s = request.site.buildbot_service
         values = s.template_values.copy()
-        values['css_path'] = self.path_to_root(request) + s.css
+        values['root'] = self.path_to_root(request)
+        # e.g. to reference the top-level 'buildbot.css' page, use
+        # "%(root)sbuildbot.css"
         values['title'] = self.getTitle(request)
         return template % values
 
@@ -170,11 +172,16 @@
         s = request.site.buildbot_service
         data = ""
         data += self.fillTemplate(s.header, request)
+        data += "<head>\n"
+        for he in s.head_elements:
+            data += " " + self.fillTemplate(he, request) + "\n"
+        data += "</head>\n\n"
 
-        data += '<body vlink="#800080">\n'
+        data += '<body %s>\n' % " ".join(['%s="%s"' % (k,v)
+                                          for (k,v) in s.body_attrs.items()])
         data += self.body(request)
         data += "</body>\n"
-        data += s.footer
+        data += self.fillTemplate(s.footer, request)
         return data
 
     def body(self, request):

Index: baseweb.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/web/baseweb.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- baseweb.py	1 Aug 2007 22:08:43 -0000	1.6
+++ baseweb.py	1 Aug 2007 22:08:47 -0000	1.7
@@ -189,14 +189,16 @@
  xmlns="http://www.w3.org/1999/xhtml"
  lang="en"
  xml:lang="en">
-
-<head>
-  <title>%(title)s</title>
-  <link href="%(css_path)s" rel="stylesheet" type="text/css" />
-</head>
-
 '''
 
+HEAD_ELEMENTS = [
+    '<title>%(title)s</title>',
+    '<link href="%(root)sbuildbot.css" rel="stylesheet" type="text/css" />',
+    ]
+BODY_ATTRS = {
+    'vlink': "#800080",
+    }
+
 FOOTER = '''
 </html>
 '''
@@ -328,8 +330,12 @@
 
         self.setupUsualPages()
 
+        # the following items are accessed by HtmlResource when it renders
+        # each page.
         self.site.buildbot_service = self
         self.header = HEADER
+        self.head_elements = HEAD_ELEMENTS[:]
+        self.body_attrs = BODY_ATTRS.copy()
         self.footer = FOOTER
         self.template_values = {}
 
@@ -403,6 +409,9 @@
 # BASEDIR/public_html/index.html, and favicon/robots.txt are provided by
 # having the admin write actual files into BASEDIR/public_html/ .
 
+# note: we don't use a util.Redirect here because HTTP requires that the
+# Location: header provide an absolute URI, and it's non-trivial to figure
+# out our absolute URI from here.
 
 class Waterfall(WebStatus):
 

Index: logs.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/status/web/logs.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- logs.py	1 Aug 2007 22:08:32 -0000	1.2
+++ logs.py	1 Aug 2007 22:08:47 -0000	1.3
@@ -156,11 +156,9 @@
         self.step_status = step_status
 
     def getChild(self, path, req):
-        try:
-            for log in self.step_status.getLogs():
-                if path == log.getName():
-                    if log.hasContents():
-                        return IHTMLLog(interfaces.IStatusLog(log))
-                    return NoResource("Empty Log '%s'" % path)
-        except (IndexError, ValueError):
-            return NoResource("No such Log '%s'" % path)
+        for log in self.step_status.getLogs():
+            if path == log.getName():
+                if log.hasContents():
+                    return IHTMLLog(interfaces.IStatusLog(log))
+                return NoResource("Empty Log '%s'" % path)
+        return NoResource("No such Log '%s'" % path)





More information about the Commits mailing list