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

Class RendererBase

source code

Known Subclasses:
Renderer, debug.Renderer, blosxom.BlosxomRenderer

Basic Renderer:

Instance Methods [hide private]
 
__init__(self, request, stdoutput=sys.stderr)
Constructor: Initializes the Renderer
source code
 
addHeader(self, *args)
Populates the HTTP header with lines of text
source code
 
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.
source code
 
render(self, header=1)
Do final rendering.
source code
 
setContent(self, content)
Sets the content
source code
 
showHeaders(self)
Updated the headers of the Response instance.
source code
 
write(self, data)
Convenience method for programs to use instead of accessing self._out.write()
source code
Method Details [hide private]

__init__(self, request, stdoutput=sys.stderr)
(Constructor)

source code 
Constructor: Initializes the Renderer
Parameters:

addHeader(self, *args)

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

needsContentType(self, flag)

source code 
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)

source code 
Do final rendering.
Parameters:
  • header (boolean) - Do we want to show headers?

setContent(self, content)

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

showHeaders(self)

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

write(self, data)

source code 

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 (string) - Piece of string you want printed