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
|