Skip to content

Commit

Permalink
Add a helper method for generating HtmlResource responses, by calling…
Browse files Browse the repository at this point in the history
… the old body() method and filling in the new layout template with the result.
  • Loading branch information
exarkun committed Nov 24, 2010
1 parent 851b8d7 commit bf9e030
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions master/buildbot/status/web/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,24 @@ def getChild(self, path, request):
return self
return resource.Resource.getChild(self, path, request)


def content(self, req, context):
"""
Generate content using the standard layout and the result of the C{body}
method.
This is suitable for the case where a resource just wants to generate
the body of a page. It depends on another method, C{body}, being
defined to accept the request object and return a C{str}. C{render}
will call this method and to generate the response body.
"""
body = self.body(req)
context['content'] = body
template = req.site.buildbot_service.templates.get_template(
"empty.html")
return template.render(**context)


def render(self, request):
# tell the WebStatus about the HTTPChannel that got opened, so they
# can close it if we get reconfigured and the WebStatus goes away.
Expand Down

0 comments on commit bf9e030

Please sign in to comment.