Falcon Repository Manager

Plugins

Falcon can be extended with plugins that hook into several parts of falcon. Falcon plugins, like falcon itself, are written in python. This documentation assumes that you know how to write python code when you start writing falconplugins. New plugins you write should be placed in ~/.falcon/plugins/ To integrate the plugin, import it in ~/.falcon/plugins/__init__.py.

Plugin skeleton

This is the most basic plugin skeleton:
# This file is a plugin for the Falcon repository manager
# Copyright (C) 2007 YOUR_NAME
# Licensing information should be placed here. For inclusion with falcon, the
# plugin must have the same license as Falcon

import falconThe falcon database
from gettext import gettext as _

class ExamplePlugin(falcon.plugin.FalconPlugin):
    """ Short description for people who read the code """
    # Plugin name, required, used in the config editor
    name = _("Example plugin")
    # Plugin description, required, used in the config editor
    desc = _("Example 'bare bones' falcon plugin")
    # API version this plugin uses. Current version can be found in config.py
    api  = (1,1)
This plugin doesn't do anything except making its presence known. To integrate this plugin with falcon, we place this in ~/.falcon/__init__.py (assuming your plugin lives in my_plugin.py)
import my_plugin

Configuration

Plugins automatically get a conf attribute, which is a Configuration object. You can register your own configuration variables, which hook into the interactive configuration editor. Registering configuration variables should be done in the __init__ method. Your plugin should not be executing anything if it's not instantiated. Example:
class ExamplePlugin(falcon.plugin.FalconPlugin):
    def __init__(self):
        self.conf.register('my_var', True, falcon.questions.Boolean(_("Do you want to rule the world?")))
The first argument to self.conf.register is the name of the variable. You can now get the value of your variable, using simple attribute access: self.conf.myvar The second argument is the default value, anything that can be pickled is OK. The third argument is a question, the available question types can be found in questions.py. For more examples, look at the standard plugins or at the main __init__.py file in the falcon folder.

Available hooks

Available hooks come in pairs, as pre and post hooks. A pre hook can raise the falcon.util.DontRun exception to prevent further plugins from doing things and to prevent the function it's wrapped around to run. (eg, raising the exception from pre_install will prevent the package from being installed.
pre_action(self, action, args)
post_action(self, action, args)
Called before/after falcon does anything useful. Config initialization is done before pre_action is called. action is a string containing the action, args is a list of arguments to the action (this is not the same as sys.argv). If you raise falcon.plugin.DontRun from the pre_action hook, falcon will exit immediately with a non-zero exitstatus. post_action is called at the end of the program.
pre_scan(self, component)
post_scan(self, result, component)
Run before/after a component is scanned. result is always None and component is the Component object that is going to be scanned.
pre_export(self, component_or_pocket)
post_export(self, result, component_or_pocket)
Run before/after a component or pocket is exported. result is always None and pocket_or_component is the Component or Pocket object that is going to be exported.
pre_install(self, component, package)
post_install(self, result, component, package)
Run before/after a package is installed into the repository. component is the destination of the package, result is False if installing failed or the same as package if installing succeeded.
pre_morgue(self, file)
post_morgue(self, result, package)
Run before/after a file is sent to the morgue or deleted. result is True if the file is actually moved or deleted of False otherwise.
pre_sync(self, mirror)
pre_rsync(self, mirror)
post_sync(self, result, mirror)
pre_build(self, builder, control, files)
post_build(self, builder, control, files)
Generated by Falcon 2.0.5 ©2005-2008 Dennis Kaarsemaker