[Buildbot-devel] jinja: user customization and public_html?

Marcus Lindblom macke at yar.nu
Sun Dec 20 16:29:31 UTC 2009

On 2009-12-20 17:10, Dustin J. Mitchell wrote:
> Sorry to self-reply, but I think I answered my own question, on
> finding this snippet in web/baseweb.py:
>          default_loader = jinja2.PackageLoader('buildbot.status.web',
> 'templates')
>          root = os.path.join(os.getcwd(), 'templates')
>          loader = jinja2.ChoiceLoader([jinja2.FileSystemLoader(root),
>                                        default_loader])
>          self.templates = jinja2.Environment(loader=loader,
>                                              extensions=['jinja2.ext.i18n'],
>                                              trim_blocks=True,
>                                              undefined=AlmostStrictUndefined)
> From what I can tell, this means that $basedir/templates can override
> built-in templates on a page-by-page basis, right?

Stefan wrote that, but what I think is, that it tries to load from an 
egg first (PackageLoader), then use the FileSystemLoader to load 
directly from disk.

So.. nope, you won't get that by default... but we could probably add 
chain another ChoiceLoader into there that looks somewhere where the 
user could put his/her custom HTML, to override specific files. (one, a 
few or all.)

We should probably not fetch custom templates in public_html, as all 
files there are served statically (albiet that index.html is overriden). 
'html_templates' might be a better name for that directory.

Note that unless you have {{ or {% in your index.html today, you can 
re-use that as is.

> I think that this needs a little bit of clarification in the texinfo
> documentation.  If you can confirm my suspicion, I'll be happy to add
> the relevant docs.

Docs & configuration are lacking a.t.m., yes. For once, the os.getcwd() 
argument to file-loader should be customizable. That what allows custom 

> Dustin
> P.S. The 'git log --graph' for buildbot/jinja is now quite a colorful
> ASCII animation!

Yeah. The github network graph also has a lot more lines in it:

http://github.com/marcusl/buildbot/network :)

but that view merges some lines, so it's not as bad as gitk. (ugh!)

I suppose one could rebase to make it look nice, but it'd be harder to 
track how every change (by others from the last 6-8 months) was adopted 
from the pre-jinja era (by me & Stefan).


More information about the devel mailing list