[Buildbot-devel] Jinja templates

Marcus Lindblom macke at yar.nu
Tue Mar 23 09:26:41 UTC 2010


On 2010-03-22 21:38, Jean-Michel Beuken wrote:
> Hello,
>
> on my production environment (bb 0.7.12, tw 8.2.0),
> I use this useful code, found in the net,  to show elapsed time for each
> steps in waterfall :
>
> -------------------------------------------------------------------
> ####### OUTPUT TWEAKING
> from twisted.python import components
> from buildbot.status.web import waterfall
> from buildbot.status.web.base import IBox
> from buildbot.status import builder
>
> class StepBox(waterfall.StepBox):
>      def getBox(self, req):
>          box = waterfall.StepBox.getBox(self, req)
> [...]
>          box.text.append('<span class="duration">%s</span>' % duration)
>          return box
> -------------------------------------------------------------------
>
> Now, I have recently installed  the new version of buildbot on a test
> machine :
>
> Version Information
>      Buildbot: latest
>      Twisted: 10.0.0
>      Jinja: 2.3.1
>      Python: 2.6.5 (r265:79063, Mar 22 2010, 00:27:11) [GCC 4.1.2
> 20080704 (Red Hat 4.1.2-46)]
>      Buildmaster platform: linux2
>
> obviously, this code doesn't work : "<type 'exceptions.AttributeError'>:
> 'unicode' object has no attribute 'append'"

That might be a bug. The box.text should probably be a list.
(The waterfall has not been, and cannot be, completely jinja-ified, 
since it computes a lot of rowspan values in python)

I can't really remember how it should be, at the moment. I suppose we 
ought to add some typechecks (somehow) and make sure it's correct 
throughout the code..

> as a tutorial, someone can show me how to transform this code to a
> "jinja"  code ?

Apart from figuring out where it goes wrong deep inside the Waterfall 
code, you could try just to add your text with a <br> in front of it:

  box.text += u'<br/><span class="duration">%s</span>' % duration

Cheers,
/Marcus





More information about the devel mailing list