6.1 pse_handler.api -- The PSE Handler API

The pse_handler.api module provides some interfaces to help you develop PSE extensions. It is usually safe to do:

from pse_handler.api import *

The members are described below.

apache
This is the mod_python.apache module, imported for your convenience.

class CustomTag( id, *arg, **kw)
This is the base class for all custom tags. Refer to Custom Tag API below for more information.

htmlquote( text)
This convenience function takes a string argument and returns the HTML encoded equivalent, with special characters replaced by their entity codes.

log_traceback( message, exc_info)
This function will log a traceback denoted by the exc_info tuple (as from sys.exc_info()) using the set PSE logging rules, prepended by the string in message.

For example, the plugin loader uses this function to report errors. If message is "plugin bad_plugin not imported due to error(s)", then the resulting output might be

[Wed Oct 19 17:38:51 2005] plugin bad_plugin not imported due to error(s): (traceback)
  File "/usr/lib/python2.4/site-packages/pse_handler/plugins/__init__.py", line
67, in load_plugins
    new_mod.initialize and new_mod.finalize
AttributeError: 'module' object has no attribute 'initialize'

write_error( text, [level])
This function makes a log entry using the set PSE logging rules. text is the message to log, and level is the severity. The severity is one of the apache logging levels defined in mod_python.apache, which defaults to mod_python.apache.APLOG_ERR. Note that the apache module is also accessible in pse_handler.api.