Back to index

plone3  3.1.7
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes
PluginRegistry.PluginRegistry.PluginRegistry Class Reference
Inheritance diagram for PluginRegistry.PluginRegistry.PluginRegistry:
Inheritance graph
[legend]
Collaboration diagram for PluginRegistry.PluginRegistry.PluginRegistry:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def listPluginTypeInfo
def listPlugins
def getPluginInfo
def listPluginIds
def activatePlugin
def deactivatePlugin
def movePluginsUp
def movePluginsDown
def manage_activatePlugins
def manage_deactivatePlugins
def manage_movePluginsUp
def manage_movePluginsDown
def getAllPlugins
def removePluginById
def getConfigAsXML
def manage_exportImport
def manage_FTPget
def PUT

Static Public Attributes

tuple security = ClassSecurityInfo()
string meta_type = 'Plugin Registry'
tuple arrow_right_gif = ImageFile( 'www/arrow-right.gif', globals() )
tuple arrow_left_gif = ImageFile( 'www/arrow-left.gif', globals() )
tuple arrow_up_gif = ImageFile( 'www/arrow-up.gif', globals() )
tuple arrow_down_gif = ImageFile( 'www/arrow-down.gif', globals() )
tuple manage_plugins = PageTemplateFile( 'plugins', _wwwdir )
tuple manage_active = PageTemplateFile( 'active_plugins', _wwwdir )
tuple manage_twoLists = PageTemplateFile( 'two_lists', _wwwdir )
tuple manage_options
tuple manage_exportImportForm = PageTemplateFile( 'export_import', _wwwdir )

Private Member Functions

def _getPlugins
def _getInterfaceFromName

Private Attributes

 _plugin_types
 _plugin_type_info

Static Private Attributes

tuple __implements__ = (WriteLockInterface,)
 _plugins = None

Detailed Description

Implement IPluginRegistry as an independent, ZMI-manageable object.

o Each plugin type holds an ordered list of ( id, wrapper ) tuples.

Definition at line 63 of file PluginRegistry.py.


Constructor & Destructor Documentation

def PluginRegistry.PluginRegistry.PluginRegistry.__init__ (   self,
  plugin_type_info = () 
)

Definition at line 84 of file PluginRegistry.py.

00084 
00085     def __init__( self, plugin_type_info=() ):
00086 
00087         if isinstance(plugin_type_info, basestring):
00088             # some tool is passing us our ID.
00089             raise ValueError('Must pass a sequence of plugin info dicts!')
00090 
00091         self._plugin_types = [x[0] for x in plugin_type_info]
00092         self._plugin_type_info = PersistentMapping()
00093         for interface in plugin_type_info:
00094             self._plugin_type_info[interface[0]] = { 
00095                   'id': interface[1]
00096                 , 'title': interface[2]
00097                 , 'description': interface[3]
00098                 }


Member Function Documentation

def PluginRegistry.PluginRegistry.PluginRegistry._getInterfaceFromName (   self,
  plugin_type_name 
) [private]
Convert the string name to an interface.

o Raise KeyError is no such interface is known.

Definition at line 413 of file PluginRegistry.py.

00413 
00414     def _getInterfaceFromName( self, plugin_type_name ):
00415 
00416         """ Convert the string name to an interface.
00417 
00418         o Raise KeyError is no such interface is known.
00419         """
00420         found = [ x[0] for x in self._plugin_type_info.items()
00421                                 if x[1][ 'id' ] == plugin_type_name ]
00422         if not found:
00423             raise KeyError, plugin_type_name
00424 
00425         if len( found ) > 1:
00426             raise KeyError, 'Waaa!:  %s' % plugin_type_name
00427 
00428         return found[ 0 ]
00429 
00430 InitializeClass( PluginRegistry )

Here is the caller graph for this function:

def PluginRegistry.PluginRegistry.PluginRegistry._getPlugins (   self,
  plugin_type 
) [private]

Definition at line 400 of file PluginRegistry.py.

00400 
00401     def _getPlugins( self, plugin_type ):
00402 
00403         parent = aq_parent( aq_inner( self ) )
00404 
00405         if plugin_type not in self._plugin_types:
00406             raise KeyError, plugin_type
00407 
00408         if self._plugins is None:
00409             self._plugins = PersistentMapping()
00410 
00411         return self._plugins.setdefault( plugin_type, () )

Here is the caller graph for this function:

def PluginRegistry.PluginRegistry.PluginRegistry.activatePlugin (   self,
  plugin_type,
  plugin_id 
)
See IPluginRegistry.

Definition at line 157 of file PluginRegistry.py.

00157 
00158     def activatePlugin( self, plugin_type, plugin_id ):
00159 
00160         """ See IPluginRegistry.
00161         """
00162         plugins = list( self._getPlugins( plugin_type ) )
00163 
00164         if plugin_id in plugins:
00165             raise KeyError, 'Duplicate plugin id: %s' % plugin_id
00166 
00167         parent = aq_parent( aq_inner( self ) )
00168         plugin = parent._getOb( plugin_id ) 
00169 
00170         if not _satisfies(plugin, plugin_type):
00171             raise ValueError, 'Plugin does not implement %s' % plugin_type 
00172         
00173         plugins.append( plugin_id )
00174         self._plugins[ plugin_type ] = tuple( plugins )

Here is the call graph for this function:

Here is the caller graph for this function:

def PluginRegistry.PluginRegistry.PluginRegistry.deactivatePlugin (   self,
  plugin_type,
  plugin_id 
)
See IPluginRegistry.

Definition at line 176 of file PluginRegistry.py.

00176 
00177     def deactivatePlugin( self, plugin_type, plugin_id ):
00178 
00179         """ See IPluginRegistry.
00180         """
00181         plugins = list( self._getPlugins( plugin_type ) )
00182 
00183         if not plugin_id in plugins:
00184             raise KeyError, 'Invalid plugin id: %s' % plugin_id
00185 
00186         plugins = [ x for x in plugins if x != plugin_id ]
00187         self._plugins[ plugin_type ] = tuple( plugins )

Here is the call graph for this function:

Here is the caller graph for this function:

Return a mapping segregating active / available plugins.

'plugin_type' is the __name__ of the interface.

Definition at line 307 of file PluginRegistry.py.

00307 
00308     def getAllPlugins( self, plugin_type ):
00309 
00310         """ Return a mapping segregating active / available plugins.
00311 
00312         'plugin_type' is the __name__ of the interface.
00313         """
00314         interface = self._getInterfaceFromName( plugin_type )
00315 
00316         active = self._getPlugins( interface )
00317         available = []
00318 
00319         for id, value in aq_parent( aq_inner( self ) ).objectItems():
00320             if _satisfies(value, interface):
00321                 if id not in active:
00322                     available.append( id )
00323 
00324         return { 'active' : active, 'available' : available }
00325 

Here is the call graph for this function:

Return XML representing the registry's configuration.

Definition at line 359 of file PluginRegistry.py.

00359 
00360         def getConfigAsXML(self):
00361             """ Return XML representing the registry's configuration.
00362             """
00363             from exportimport import PluginRegistryExporter
00364             pre = PluginRegistryExporter(self).__of__(self)
00365             return pre.generateXML()

Here is the caller graph for this function:

See IPluginRegistry.

Definition at line 141 of file PluginRegistry.py.

00141 
00142     def getPluginInfo( self, plugin_type ):
00143 
00144         """ See IPluginRegistry.
00145         """
00146         plugin_type = self._getInterfaceFromName( plugin_type )
00147         return self._plugin_type_info[plugin_type]

Here is the call graph for this function:

See IPluginRegistry.

Definition at line 149 of file PluginRegistry.py.

00149 
00150     def listPluginIds( self, plugin_type ):
00151 
00152         """ See IPluginRegistry.
00153         """
00154 
00155         return self._getPlugins( plugin_type )

Here is the call graph for this function:

See IPluginRegistry.

Definition at line 120 of file PluginRegistry.py.

00120 
00121     def listPlugins( self, plugin_type ):
00122 
00123         """ See IPluginRegistry.
00124         """
00125         result = []
00126 
00127         parent = aq_parent( aq_inner( self ) )
00128 
00129         for plugin_id in self._getPlugins( plugin_type ):
00130 
00131             plugin = parent._getOb( plugin_id )
00132             if not _satisfies( plugin, plugin_type ):
00133                 logger.debug( 'Active plugin %s no longer implements %s'
00134                                 % ( plugin_id, plugin_type )
00135                             )
00136             else:
00137                 result.append( ( plugin_id, plugin ) )
00138 
00139         return result

Here is the call graph for this function:

See IPluginRegistry.

Definition at line 103 of file PluginRegistry.py.

00103 
00104     def listPluginTypeInfo( self ):
00105 
00106         """ See IPluginRegistry.
00107         """
00108         result = []
00109 
00110         for ptype in self._plugin_types:
00111 
00112             info = self._plugin_type_info[ptype].copy()
00113             info['interface'] = ptype
00114             info['methods'] = ptype.names()
00115 
00116             result.append( info )
00117 
00118         return result

def PluginRegistry.PluginRegistry.PluginRegistry.manage_activatePlugins (   self,
  plugin_type,
  plugin_ids,
  RESPONSE 
)
Shim into ZMI.

Definition at line 250 of file PluginRegistry.py.

00250 
00251                              ):
00252         """ Shim into ZMI.
00253         """
00254         interface = self._getInterfaceFromName( plugin_type )
00255         for id in plugin_ids:
00256             self.activatePlugin( interface, id )
00257         RESPONSE.redirect( '%s/manage_plugins?plugin_type=%s'
00258                          % ( self.absolute_url(), plugin_type )
00259                          )

Here is the call graph for this function:

def PluginRegistry.PluginRegistry.PluginRegistry.manage_deactivatePlugins (   self,
  plugin_type,
  plugin_ids,
  RESPONSE 
)
Shim into ZMI.

Definition at line 265 of file PluginRegistry.py.

00265 
00266                                 ):
00267         """ Shim into ZMI.
00268         """
00269         interface = self._getInterfaceFromName( plugin_type )
00270         for id in plugin_ids:
00271             self.deactivatePlugin( interface, id )
00272 
00273         RESPONSE.redirect( '%s/manage_plugins?plugin_type=%s'
00274                          % ( self.absolute_url(), plugin_type )
00275                          )

Here is the call graph for this function:

Here is the caller graph for this function:

def PluginRegistry.PluginRegistry.PluginRegistry.manage_exportImport (   self,
  updated_xml,
  should_purge,
  RESPONSE 
)
Parse XML and update the registry.

Definition at line 367 of file PluginRegistry.py.

00367 
00368         def manage_exportImport(self, updated_xml, should_purge, RESPONSE):
00369             """ Parse XML and update the registry.
00370             """
00371             #XXX encoding?
00372             _updatePluginRegistry(self, updated_xml, should_purge)
00373             RESPONSE.redirect('%s/manage_exportImportForm'
00374                               '?manage_tabs_message=Registry+updated.'
00375                                 % self.absolute_url())

Here is the call graph for this function:

def PluginRegistry.PluginRegistry.PluginRegistry.manage_FTPget (   self,
  REQUEST,
  RESPONSE 
)

Definition at line 377 of file PluginRegistry.py.

00377 
00378         def manage_FTPget(self, REQUEST, RESPONSE):
00379             """
00380             """
00381             return self.getConfigAsXML()

Here is the call graph for this function:

def PluginRegistry.PluginRegistry.PluginRegistry.manage_movePluginsDown (   self,
  plugin_type,
  plugin_ids,
  RESPONSE 
)
Shim into ZMI.

Definition at line 296 of file PluginRegistry.py.

00296 
00297                               ):
00298         """ Shim into ZMI.
00299         """
00300         interface = self._getInterfaceFromName( plugin_type )
00301         self.movePluginsDown( interface, plugin_ids )
00302 
00303         RESPONSE.redirect( '%s/manage_plugins?plugin_type=%s'
00304                          % ( self.absolute_url(), plugin_type )
00305                          )

Here is the call graph for this function:

Here is the caller graph for this function:

def PluginRegistry.PluginRegistry.PluginRegistry.manage_movePluginsUp (   self,
  plugin_type,
  plugin_ids,
  RESPONSE 
)
Shim into ZMI.

Definition at line 281 of file PluginRegistry.py.

00281 
00282                             ):
00283         """ Shim into ZMI.
00284         """
00285         interface = self._getInterfaceFromName( plugin_type )
00286         self.movePluginsUp( interface, plugin_ids )
00287 
00288         RESPONSE.redirect( '%s/manage_plugins?plugin_type=%s'
00289                          % ( self.absolute_url(), plugin_type )
00290                          )

Here is the call graph for this function:

Here is the caller graph for this function:

def PluginRegistry.PluginRegistry.PluginRegistry.movePluginsDown (   self,
  plugin_type,
  ids_to_move 
)
See IPluginRegistry.

Definition at line 213 of file PluginRegistry.py.

00213 
00214     def movePluginsDown( self, plugin_type, ids_to_move ):
00215 
00216         """ See IPluginRegistry.
00217         """
00218         ids = list( self._getPlugins( plugin_type ) )
00219         count = len( ids )
00220 
00221         indexes = list( map( ids.index, ids_to_move ) )
00222         indexes.sort()
00223         indexes.reverse()
00224 
00225         for i1 in indexes:
00226 
00227             if i1 < 0 or i1 >= count:
00228                 raise IndexError, i1
00229 
00230             i2 = i1 + 1
00231             if i2 == len( ids ):      # wrap to top
00232                 i2 = 0
00233 
00234             ids[ i2 ], ids[ i1 ] = ids[ i1 ], ids[ i2 ]
00235 
00236         self._plugins[ plugin_type ] = tuple( ids )

Here is the call graph for this function:

Here is the caller graph for this function:

def PluginRegistry.PluginRegistry.PluginRegistry.movePluginsUp (   self,
  plugin_type,
  ids_to_move 
)
See IPluginRegistry.

Definition at line 189 of file PluginRegistry.py.

00189 
00190     def movePluginsUp( self, plugin_type, ids_to_move ):
00191 
00192         """ See IPluginRegistry.
00193         """
00194         ids = list( self._getPlugins( plugin_type ) )
00195         count = len( ids )
00196 
00197         indexes = list( map( ids.index, ids_to_move ) )
00198         indexes.sort()
00199 
00200         for i1 in indexes:
00201 
00202             if i1 < 0 or i1 >= count:
00203                 raise IndexError, i1
00204 
00205             i2 = i1 - 1
00206             if i2 < 0:      # wrap to bottom
00207                 i2 = len( ids ) - 1
00208 
00209             ids[ i2 ], ids[ i1 ] = ids[ i1 ], ids[ i2 ]
00210 
00211         self._plugins[ plugin_type ] = tuple( ids )

Here is the call graph for this function:

Here is the caller graph for this function:

def PluginRegistry.PluginRegistry.PluginRegistry.PUT (   self,
  REQUEST,
  RESPONSE 
)

Definition at line 383 of file PluginRegistry.py.

00383 
00384         def PUT(self, REQUEST, RESPONSE):
00385             """
00386             """
00387             xml = REQUEST['BODYFILE'].read()
00388             _updatePluginRegistry(self, xml, True)

Here is the call graph for this function:

Remove a plugin from any plugin types which have it configured.

Definition at line 327 of file PluginRegistry.py.

00327 
00328     def removePluginById( self, plugin_id ):
00329 
00330         """ Remove a plugin from any plugin types which have it configured.
00331         """
00332         for plugin_type in self._plugin_types:
00333 
00334             if plugin_id in self._getPlugins( plugin_type ):
00335                 self.deactivatePlugin( plugin_type, plugin_id )

Here is the call graph for this function:


Member Data Documentation

tuple PluginRegistry.PluginRegistry.PluginRegistry.__implements__ = (WriteLockInterface,) [static, private]

Definition at line 74 of file PluginRegistry.py.

Definition at line 91 of file PluginRegistry.py.

Definition at line 90 of file PluginRegistry.py.

Definition at line 82 of file PluginRegistry.py.

tuple PluginRegistry.PluginRegistry.PluginRegistry.arrow_down_gif = ImageFile( 'www/arrow-down.gif', globals() ) [static]

Definition at line 243 of file PluginRegistry.py.

tuple PluginRegistry.PluginRegistry.PluginRegistry.arrow_left_gif = ImageFile( 'www/arrow-left.gif', globals() ) [static]

Definition at line 241 of file PluginRegistry.py.

tuple PluginRegistry.PluginRegistry.PluginRegistry.arrow_right_gif = ImageFile( 'www/arrow-right.gif', globals() ) [static]

Definition at line 240 of file PluginRegistry.py.

tuple PluginRegistry.PluginRegistry.PluginRegistry.arrow_up_gif = ImageFile( 'www/arrow-up.gif', globals() ) [static]

Definition at line 242 of file PluginRegistry.py.

tuple PluginRegistry.PluginRegistry.PluginRegistry.manage_active = PageTemplateFile( 'active_plugins', _wwwdir ) [static]

Definition at line 339 of file PluginRegistry.py.

tuple PluginRegistry.PluginRegistry.PluginRegistry.manage_exportImportForm = PageTemplateFile( 'export_import', _wwwdir ) [static]

Definition at line 356 of file PluginRegistry.py.

Initial value:
( ( { 'label'  : 'Plugins'
                       , 'action' : 'manage_plugins'
                     # , 'help'   : ( 'PluggableAuthService'
                     #              , 'plugins.stx')
                       }
                     , { 'label'  : 'Active'
                       , 'action' : 'manage_active'
                       }
                     )
                   + SimpleItem.manage_options
                   )

Definition at line 342 of file PluginRegistry.py.

tuple PluginRegistry.PluginRegistry.PluginRegistry.manage_plugins = PageTemplateFile( 'plugins', _wwwdir ) [static]

Definition at line 337 of file PluginRegistry.py.

tuple PluginRegistry.PluginRegistry.PluginRegistry.manage_twoLists = PageTemplateFile( 'two_lists', _wwwdir ) [static]

Definition at line 340 of file PluginRegistry.py.

string PluginRegistry.PluginRegistry.PluginRegistry.meta_type = 'Plugin Registry' [static]

Definition at line 80 of file PluginRegistry.py.

tuple PluginRegistry.PluginRegistry.PluginRegistry.security = ClassSecurityInfo() [static]

Definition at line 78 of file PluginRegistry.py.


The documentation for this class was generated from the following file: