Package Pyblosxom :: Package renderers :: Module base :: Class RendererBase
[show private | hide private]
[frames | no frames]

Class RendererBase

Known Subclasses:
BlosxomRenderer, Renderer, Renderer

Basic Renderer:
Method Summary
  __init__(self, request, stdoutput)
Constructor: Initializes the Renderer
  addHeader(self, *args)
Populates the HTTP header with lines of text
  needsContentType(self, flag)
Use the renderer to determine 'Content-Type: x/x' default is to use the renderer for Content-Type, set flag to None to indicate no Content-Type generation.
  render(self, header)
Do final rendering.
  setContent(self, content)
Sets the content
  showHeaders(self)
Updated the headers of the Response instance.
  write(self, data)
Convenience method for programs to use instead of accessing self._out.write()

Method Details

__init__(self, request, stdoutput=<epydoc.imports._DevNull instance at 0x4021768c>)
(Constructor)

Constructor: Initializes the Renderer
Parameters:
request - The Pyblosxom.pyblosxom.Request object
           (type=Pyblosxom.pyblosxom.Request object)
stdoutput - File like object to print to.
           (type=file)

addHeader(self, *args)

Populates the HTTP header with lines of text
Parameters:
args - Paired list of headers
           (type=argument lists)
Raises:
ValueError - This happens when the parameters are not correct

needsContentType(self, flag)

Use the renderer to determine 'Content-Type: x/x' default is to use the renderer for Content-Type, set flag to None to indicate no Content-Type generation.
Parameters:
flag - True of false value

render(self, header=1)

Do final rendering.
Parameters:
header - Do we want to show headers?
           (type=boolean)

setContent(self, content)

Sets the content
Parameters:
content - What content are we to show?
           (type=list List of entries to process or dict Simple dict containing at least 'title' and 'body')

showHeaders(self)

Updated the headers of the Response instance. This is just for backwards compatibility.

write(self, data)

Convenience method for programs to use instead of accessing self._out.write()

Other classes can override this if there is a unique way to write out data, for example, a two stream output, e.g. one output stream and one output log stream.

Another use for this could be a plugin that writes out binary files, but because renderers and other frameworks may probably not want you to write to stdout directly, this method assists you nicely. For example:
   def cb_start(args):
       req = args['request']
       renderer = req['renderer']

       if reqIsGif and gifFileExists(theGifFile):
           # Read the file
           data = open(theGifFile).read()
           
           # Modify header
           renderer.addHeader('Content-type', 'image/gif')
           renderer.addHeader('Content-Length', len(data))
           renderer.showHeaders()

           # Write to output
           renderer.write(data)

           # Tell pyblosxom not to render anymore as data is
           # processed already
           renderer.rendered = 1
This simple piece of pseudocode explains what you could do with this method, though I highly don't recommend this, unless pyblosxom is running continuously.
Parameters:
data - Piece of string you want printed
           (type=string)

Generated by Epydoc 2.1 on Tue Feb 7 21:43:58 2006 http://epydoc.sf.net