Re: Setting depth with the flav_config plugin
Stuart Langridge <[email protected]>
| Newsgroups | gmane.comp.web.pyblosxom.user |
|---|---|
| Message-ID | <[email protected]> |
will guaraldi wrote:
> The easy way to do this is to write a renderer plugin that handles
> CheetahTemplates. You should look at the base renderer class and get a
> feel for how PyBlosxom interfaces with the renderer. After that, it
> should be pretty easy to implement--especially if you've already used
> Cheetah templates before.
OK, a noddy implementation is below. I've assumed that the only things
that are substituted in Pyblosxom templates are attributes of an Entry.
The below seems to work in my (rather minimal) testing...
sil
"""
Use CheetahTemplate to render templates.
"""
__author__ = "Stuart Langridge - http://www.kryogenix/org/"
__version__ = "1.0 2004-12-05"
__url__ = "about:blank"
__description__ = "Render templates with CheetahTemplate"
import re
from Pyblosxom.renderers.blosxom import BlosxomRenderer
try:
from Cheetah.Template import Template
except:
pass
def verify_installation(req):
try:
import Cheetah
return 1
except:
print "CheetahTemplate must be installed!"
return 0
def printTemplate(self,entry,template):
"""
@param entry: either a dict or the Entry object
@type entry: dict or Entry
@param template: the template string
@type template: string
@returns: the content string
@rtype: string
"""
if template and Template:
template = unicode(template)
t = Template(source=template,searchList=[entry])
return str(t)
return ""
def cb_renderer(args):
"""Return a new Cheetah renderer.
Since this is all exactly the same as the pyblosxom default renderer,
we just override one method."""
request = args['request']
newRenderer = BlosxomRenderer
newRenderer._printTemplate = printTemplate
rendererInstance = newRenderer(request)
return rendererInstance
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/