Package Pyblosxom :: Module plugin_utils
[hide private]
[frames] | no frames]

Module plugin_utils

source code

Holds a series of utility functions for cataloguing, retrieving, and manipulating callback functions and chains. Refer to the documentation for which callbacks are available and their behavior.

Functions [hide private]
 
catalogue_plugin(plugin_module)
Goes through the plugin's contents and catalogues all the functions that start with cb_.
source code
list of functions
get_callback_chain(chain)
Returns a list of functions registered with the callback.
source code
 
initialize_plugins(plugin_dirs, plugin_list)
Imports and initializes plugins from the directories in the list specified by "plugins_dir".
source code
Python module
get_plugin_by_name(name)
This retrieves a plugin instance (it's a Python module instance) by name.
source code
string
get_module_name(filename)
Takes a filename and returns the module name from the filename.
source code
list of strings
get_plugin_list(plugin_list, plugin_dirs)
This handles the situation where the user has provided a series of plugin dirs, but has not specified which plugins they want to load from those dirs.
source code
Variables [hide private]
  __revision__ = '$Revision: 1012 $'
  plugins = []
  callbacks = {}
Function Details [hide private]

catalogue_plugin(plugin_module)

source code 
Goes through the plugin's contents and catalogues all the functions that start with cb_. Functions that start with cb_ are callbacks.
Parameters:
  • plugin_module (module) - the module to catalogue

get_callback_chain(chain)

source code 
Returns a list of functions registered with the callback.
Returns: list of functions
list of functions registered with the callback (or an empty list)

initialize_plugins(plugin_dirs, plugin_list)

source code 

Imports and initializes plugins from the directories in the list specified by "plugins_dir". If no such list exists, then we don't load any plugins.

If the user specifies a "load_plugins" list of plugins to load, then we explicitly load those plugins in the order they're listed. If the load_plugins key does not exist, then we load all the plugins in the plugins directory using an alphanumeric sorting order.

NOTE: If PyBlosxom is part of a long-running process, you must restart PyBlosxom in order to pick up any changes to your plugins.
Parameters:
  • plugin_dirs (list of strings) - the list of directories to add to the sys.path because that's where our plugins are located.
  • plugin_list (list of strings or None) - the list of plugins to load, or if None, we'll load all the plugins we find in those dirs.

get_plugin_by_name(name)

source code 
This retrieves a plugin instance (it's a Python module instance) by name.
Parameters:
  • name (string) - the name of the plugin to retrieve (ex: "xmlrpc")
Returns: Python module
the Python module instance for the plugin or None

get_module_name(filename)

source code 

Takes a filename and returns the module name from the filename.

Example: passing in "/blah/blah/blah/module.ext" returns "module"
Parameters:
  • filename (string) - the filename in question (with a full path)
Returns: string
the filename without path or extension

get_plugin_list(plugin_list, plugin_dirs)

source code 
This handles the situation where the user has provided a series of plugin dirs, but has not specified which plugins they want to load from those dirs. In this case, we load all possible plugins except the ones whose names being with _ .
Parameters:
  • plugin_list (list or None) - List of plugins to load
  • plugin_dirs (list) - A list of directories where plugins can be loaded from
Returns: list of strings
list of python module names of the plugins to load