Package buildbot :: Package status :: Package web :: Module changes
[frames] | no frames]

Source Code for Module buildbot.status.web.changes

 1   
 2  from zope.interface import implements 
 3  from twisted.python import components 
 4  from twisted.web.error import NoResource 
 5   
 6  from buildbot.changes.changes import Change 
 7  from buildbot.status.web.base import HtmlResource, IBox, Box 
 8   
9 -class ChangeResource(HtmlResource):
10 - def __init__(self, change, num):
11 self.change = change 12 self.title = "Change #%d" % num
13
14 - def content(self, req, cxt):
15 cxt['c'] = self.change.asDict() 16 template = req.site.buildbot_service.templates.get_template("change.html") 17 data = template.render(cxt) 18 return data
19 20 # /changes/NN
21 -class ChangesResource(HtmlResource):
22
23 - def content(self, req, cxt):
24 cxt['sources'] = self.getStatus(req).getChangeSources() 25 template = req.site.buildbot_service.templates.get_template("change_sources.html") 26 return template.render(**cxt)
27 28
29 - def getChild(self, path, req):
30 try: 31 num = int(path) 32 c = self.getStatus(req).getChange(num) 33 except ValueError: 34 c = None 35 num = path 36 if not c: 37 return NoResource("No change number '%s'" % path) 38 return ChangeResource(c, num)
39
40 -class ChangeBox(components.Adapter):
41 implements(IBox) 42
43 - def getBox(self, req):
44 url = req.childLink("../changes/%d" % self.original.number) 45 template = req.site.buildbot_service.templates.get_template("change_macros.html") 46 text = template.module.box_contents(url=url, 47 who=self.original.getShortAuthor(), 48 title=self.original.comments) 49 return Box([text], class_="Change")
50 components.registerAdapter(ChangeBox, Change, IBox) 51