The Occasional Occurence

Buffet 1.0 - A flexible templating filter for CherryPy

August 12, 2006 at 08:57 PM | categories: Python, cherrypy, General

I released Buffet 1.0 today. No huge changes from 0.9, but a couple decent accomplishments.

Unit Tests One of my goals for releasing a 1.0 version was to have unit tests for Buffet. Well, they are in there now. If nothing else, I feel a lot better about the code now that it has to jump through some basic hoops :-)

Flexible Configuration In 0.9, Buffet would look in your CherryPy config file for a section called "plugin_name_settings". These config entries were then passed on to the template plugin in question.

The main problem with that approach was handling multiple apps within a single process. Say you wanted to host two apps using BuffetMyghty and have to separate Myghty component_roots. Well, it wasn't possible, because both instances of the buffet.TemplateFilter would look for a myghty_settings config section and pass the settings found there to the BuffetMyghty plugin.

Now, you can pass an optional config_section parameter to the TemplateFilter's constructor. You can specify a Myghty component_root in a config section called 'app1' and another in 'app2' and pass the section names respectively to each app's TemplateFilter and have individual configurations.

For backwards compatibility, config_section defaults to the old "plugin_name_settings" convention.

Other Changes Buffet is now a CherryPy 2.2.x filter. If you need to use it with a 2.1.x application, you can use version 0.9. The configuration change is the main difference and it doesn't apply as much to 2.1 anyhow since it is not as friendly for hosting multiple apps in a single process.

One thing that I mentioned as a goal for 1.0 but that I didn't implement was profiling. It seemed a bit overkill for the sort of templating middleware that it is. The biggest potential performance hits are going to be on either side of Buffet (controller logic and templating logic). If anyone thinks having profiling is a big deal, feel free to convince me :-)

Finally, in case you missed my earlier posting, Buffet is now housed in a public subversion repository. Thanks Webfaction!

p.s. - Be on the lookout for an improved version of the BuffetMyghty plugin when I get the time to release it! I'm rolling some changes back in from the fork of the plugin used in Pylons. For now you can peek at the code in svn.