Back to index

plone3  3.1.7
Classes | Functions | Variables
PluginRegistry.exportimport Namespace Reference

Classes

class  PluginRegistryExporter
class  PluginRegistryImporter
class  PluginRegistryFileExportImportAdapter

Functions

def _providedBy
def _getRegistry
def exportPluginRegistry
def _updatePluginRegistry
def importPluginRegistry

Variables

string _FILENAME = 'pluginregistry.xml'

Function Documentation

def PluginRegistry.exportimport._getRegistry (   site) [private]

Definition at line 47 of file exportimport.py.

00047 
00048 def _getRegistry(site):
00049     registries = [x for x in site.objectValues()
00050                     if _providedBy(x, IPluginRegistry)]
00051 
00052     if len(registries) < 1:
00053         raise ValueError, 'No plugin registries'
00054 
00055     if len(registries) > 1:
00056         raise ValueError, 'Too many plugin registries'
00057 
00058     return registries[0]

Here is the call graph for this function:

Here is the caller graph for this function:

def PluginRegistry.exportimport._providedBy (   obj,
  iface 
) [private]

Definition at line 39 of file exportimport.py.

00039 
00040 def _providedBy(obj, iface):
00041     try:
00042         return iface.providedBy(obj)
00043     except AttributeError:
00044         return iface.isImplementedBy(obj) # Z2 interfaces

Here is the caller graph for this function:

def PluginRegistry.exportimport._updatePluginRegistry (   registry,
  xml,
  should_purge,
  encoding = None 
) [private]

Definition at line 71 of file exportimport.py.

00071 
00072 def _updatePluginRegistry(registry, xml, should_purge, encoding=None):
00073 
00074     if should_purge:
00075 
00076         registry._plugin_types = []
00077         registry._plugin_type_info = PersistentMapping()
00078         registry._plugins = PersistentMapping()
00079 
00080     pir = PluginRegistryImporter(registry, encoding)
00081     reg_info = pir.parseXML(xml)
00082 
00083     for info in reg_info['plugin_types']:
00084         iface = _resolveDottedName(info['interface'])
00085         # Avoid duplicate plugin types
00086         if iface not in registry._plugin_types:
00087             registry._plugin_types.append(iface)
00088         registry._plugin_type_info[iface] = {'id': info['id'],
00089                                              'title': info['title'],
00090                                              'description': info['description'],
00091                                             }
00092         registry._plugins[iface] = tuple([x['id'] for x in info['plugins']])

Here is the call graph for this function:

Here is the caller graph for this function:

Export plugin registry as an XML file.

o Designed for use as a GenericSetup export step.

Definition at line 59 of file exportimport.py.

00059 
00060 def exportPluginRegistry(context):
00061     """ Export plugin registry as an XML file.
00062 
00063     o Designed for use as a GenericSetup export step.
00064     """
00065     registry = _getRegistry(context.getSite())
00066     pre = PluginRegistryExporter(registry).__of__(registry)
00067     xml = pre.generateXML()
00068     context.writeDataFile(_FILENAME, xml, 'text/xml')
00069 
00070     return 'Plugin registry exported.'

Here is the call graph for this function:

Here is the caller graph for this function:

Import plugin registry from an XML file.

o Designed for use as a GenericSetup import step.

Definition at line 93 of file exportimport.py.

00093 
00094 def importPluginRegistry(context):
00095     """ Import plugin registry from an XML file.
00096 
00097     o Designed for use as a GenericSetup import step.
00098     """
00099     registry = _getRegistry(context.getSite())
00100     encoding = context.getEncoding()
00101 
00102     xml = context.readDataFile(_FILENAME)
00103     if xml is None:
00104         return 'Site properties: Nothing to import.'
00105 
00106     _updatePluginRegistry(registry, xml, context.shouldPurge(), encoding)
00107 
00108     return 'Plugin registry imported.'

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

string PluginRegistry.exportimport._FILENAME = 'pluginregistry.xml'

Definition at line 45 of file exportimport.py.