[PyCS-devel] RFC: templating system proposal
Status: Alpha
Brought to you by:
myelin
|
From: Georg B. <gb...@mu...> - 2002-12-10 12:15:50
|
Hi! I again looked at templating systems for python and stumbled across Cheetah, the templatingsystem behind webware. This can easily be used without webware, is a simple setup.py install and quite simple to use. And it goes IMO nicely with the other toolkits we use, PyCS goes more for the simple and small than for the big and bloated (we do use Metakit and not some big database). The homepage: http://www.cheetahtemplate.org/ A quite good summary on cheetah and comparisons with other templating systems (especially a reasoning why not ZPT): http://www.cheetahtemplate.org/Py10.html The users guide for using cheetah: http://www.cheetahtemplate.org/docs/users_guide_html/ If somebody want's to install it into the pycs python: # this is one line, press enter for the password cd $HOME/src/cvs -d:pserver:ano...@cv...:/cvsroot/cheetahtemplate login # this is one line cvs -d:pserver:ano...@cv...:/cvsroot/cheetahtemplate co Cheetah cd $HOME/src/Cheetah $HOME/pycs/bin/python setup.py build $HOME/pycs/bin/python setup.py install I think it is quite nice, templates have useable template language with the usual language constructs, although it doesn't follow the "everything tags and attributes" line like ZPT or DTML or PSP. The benefit is, you can use cheetah for every fileformat you want, even if it isn't some tagbased format. The usage of templates is quite simple (transliterated from the doc): from Cheetah.Template import Template templateDef = ("<html><head><title>$title</title></head>" + "<body><h1>$title</h1>$body</body></html>") class myTemplate(Template): title = "test" body = "test" templ = myTemplate(templateDef) print templ templ.title = "test" templ.body = "Another test" print templ This makes quite nice python code, and the template language isn't too bad. So I would say "go for it", if there are no objections to this package. Comments? bye, Georg |