Re: Renderer plugins

Steven Armstrong <[email protected]>
Newsgroups gmane.comp.web.pyblosxom.user
Message-ID <[email protected]>
Ross Burton wrote:
> 
> Hm, still doesn't work.
> 
> renderers/blosxom.py in render(), line 212
> 
> data['content-type'] = self.flavour['content_type'].strip()
> 
> KeyError: 'content_type'
> 
> It appears that I can't use the default renderer and just throw data
> into it, like the source says I can. :(
> 
>> ps: I thought the content-type for rdf was application/rdf+xml, is it not?
> 
> Yep, that's a typo in my code-refactoring when I was trying to find the
> bug...
> 

That's weird ... it's working here ...? ...?

You could try one of the following 3 versions (all working here):

####### start

from Pyblosxom.renderers.base import RendererBase
class DOAPRenderer(RendererBase):
    def render(self, header=1):
        config = self._request.getConfiguration()
        pyhttp = self._request.getHttp()
        data = open(config["datadir"] + pyhttp["PATH_INFO"]).read()
        self.addHeader('Content-Type', 'application/rdf+xml')
        self.addHeader('Content-Length', str(len(data)))
        self.showHeaders()
        self.write(data)

def cb_renderer(args):
    request = args['request']
    pyhttp = request.getHttp()
    config = request.getConfiguration()
    if pyhttp['PATH_INFO'].endswith("doap.rdf"):
        import sys
        return DOAPRenderer(request,
            config.get('stdoutput', sys.stdout))

#def cb_handle(args):
#    request = args['request']
#    pyhttp = request.getHttp()
#    config = request.getConfiguration()
#    if pyhttp["PATH_INFO"].endswith("doap.rdf"):
#        data = open(config["datadir"] + pyhttp["PATH_INFO"]).read()
#
#        # note: this may not work with pyblosxom 1.1+ versions
#        out = config['stdoutput']
#        out.write('Content-type: application/rdf+xml\n')
#        out.write('Content-Length: %d\n\n' % len(data))
#        out.write(data)
#        out.flush()
#
#        # return True to tell pyblosxom that
#        # the request has been taken care of
#        return 1

#def cb_pathinfo(args):
#    request = args['request']
#    pyhttp = request.getHttp()
#    config = request.getConfiguration()
#    renderer = request.getData()['renderer']
#    if pyhttp["PATH_INFO"].endswith("doap.rdf"):
#        data = open(config["datadir"] + pyhttp["PATH_INFO"]).read()
#        renderer.addHeader('Content-type', 'application/rdf+xml')
#        renderer.addHeader('Content-Length', str(len(data)))
#        renderer.needsContentType(0)
#        renderer.showHeaders()
#        renderer.write(data)
#        renderer.rendered = 1



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.