Package base :: Package includes :: Module plugin
[hide private]

Module plugin

source code

API for loading and interacting with Drupal plugins.
See Also:
Drupy Homepage, Drupal Homepage
Notes:

Author: Brendon Crawford

Copyright: 2008 Brendon Crawford

Contact: message144 at users dot sourceforge dot net

Version: 0.1

Functions [hide private]
 
load_all()
Load all the plugins that have been enabled in the system table.
source code
 
list_(refresh=False, bootstrap=True, sort=False, fixed_list=None)
Collect a list of all loaded plugins.
source code
 
rebuild_cache()
Rebuild the database cache of plugin files.
source code
 
_build_dependencies(files)
Find dependencies any level deep and fill in dependents information too.
source code
 
exists(plugin_)
Determine whether a given plugin exists.
source code
 
load_install(plugin_)
Load a plugin's installation hooks.
source code
 
load_include(type_, plugin_, name=None)
Load a plugin include file.
source code
 
load_all_includes(type_, name=None)
Load an include file for each of the plugins that have been enabled in the system table.
source code
 
enable(plugin_list_)
Enable a given list of plugins.
source code
 
disable(plugin_list_)
Disable a given set of plugins.
source code
 
hook(plugin_, hook_)
Determine whether a plugin implements a hook.
source code
 
implements(hook_, sort=False, refresh=False)
Determine which plugins are implementing a hook.
source code
 
invoke(plugin_, hook_, *args)
Invoke a hook in a particular plugin.
source code
 
invoke_all(*args)
Invoke a hook in all enabled plugins that implement it.
source code
 
drupal_required_plugins()
Array of plugins required by core.
source code
Variables [hide private]
  __version__ = '$Revision: 1 $'
  plugins = {'node': <module 'plugins.node' from '/Users/brendon...
Function Details [hide private]

list_(refresh=False, bootstrap=True, sort=False, fixed_list=None)

source code 
Collect a list of all loaded plugins. During the bootstrap, return only vital plugins. See bootstrap.inc
Parameters:
  • refresh - Whether to force the plugin list to be regenerated (such as after the administrator has changed the system settings).
  • bootstrap - Whether to return the reduced set of plugins loaded in "bootstrap mode" for cached pages. See bootstrap.inc.
  • sort - By default, plugins are ordered by weight and filename, settings this option to True, plugin list will be ordered by plugin name.
  • fixed_list - (Optional) Override the plugin list with the given plugins. Stays until the next call with refresh = True.
Returns:
An associative array whose keys and values are the names of all loaded plugins.

rebuild_cache()

source code 
Rebuild the database cache of plugin files.
Returns:
The array of filesystem objects used to rebuild the cache.

_build_dependencies(files)

source code 
Find dependencies any level deep and fill in dependents information too. If plugin A depends on B which in turn depends on C then this function will add C to the list of plugins A depends on. This will be repeated until plugin A has a list of all plugins it depends on. If it depends on itself, called a circular dependency, that's marked by adding a nonexistent plugin, called -circular- to this list of plugins. Because this does not exist, it'll be impossible to switch plugin A on. Also we fill in a dependents array in file.info. Using the names above, the dependents array of plugin B lists A.
Parameters:
  • files - The array of filesystem objects used to rebuild the cache.
Returns:
The same array with dependencies and dependents added where applicable.

exists(plugin_)

source code 
Determine whether a given plugin exists.
Parameters:
  • plugin - The name of the plugin (without the .plugin extension).
Returns:
True if the plugin is both installed and enabled.

load_include(type_, plugin_, name=None)

source code 
Load a plugin include file.
Parameters:
  • type - The include file's type (file extension).
  • plugin - The plugin to which the include file belongs.
  • name - Optionally, specify the file name. If not set, the plugin's name is used.

enable(plugin_list_)

source code 
Enable a given list of plugins.
Parameters:
  • plugin_list - An array of plugin names.

disable(plugin_list_)

source code 
Disable a given set of plugins.
Parameters:
  • plugin_list - An array of plugin names.

hook(plugin_, hook_)

source code 
Determine whether a plugin implements a hook.
Parameters:
  • plugin - The name of the plugin (without the .plugin extension).
  • hook - The name of the hook (e.g. "help" or "menu").
Returns:
True if the plugin is both installed and enabled, and the hook is implemented in that plugin.

implements(hook_, sort=False, refresh=False)

source code 
Determine which plugins are implementing a hook.
Parameters:
  • hook - The name of the hook (e.g. "help" or "menu").
  • sort - By default, plugins are ordered by weight and filename, settings this option to True, plugin list will be ordered by plugin name.
  • refresh - For internal use only: Whether to force the stored list of hook implementations to be regenerated (such as after enabling a new plugin, before processing hook_enable).
Returns:
An array with the names of the plugins which are implementing this hook.

invoke(plugin_, hook_, *args)

source code 
Invoke a hook in a particular plugin.
Parameters:
  • plugin - The name of the plugin (without the .plugin extension).
  • hook - The name of the hook to invoke.
  • ... - Arguments to pass to the hook implementation.
Returns:
The return value of the hook implementation.

invoke_all(*args)

source code 
Invoke a hook in all enabled plugins that implement it.
Parameters:
  • hook - The name of the hook to invoke.
  • ... - Arguments to pass to the hook.
Returns:
An array of return values of the hook implementations. If plugins return arrays from their implementations, those are merged into one array.

Variables Details [hide private]

plugins

Value:
{'node': <module 'plugins.node' from '/Users/brendon/work/projects/Pyt\
honDrupal/drupy/base/plugins/node/__init__.py'>,
 'system': <module 'plugins.system' from '/Users/brendon/work/projects\
/PythonDrupal/drupy/base/plugins/system/__init__.pyc'>,
 'user': <module 'plugins.user' from '/Users/brendon/work/projects/Pyt\
honDrupal/drupy/base/plugins/user/__init__.pyc'>}