Back to index

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

List of all members.

Public Member Functions

def sortSteps
def checkComplete
def registerStep
def listSteps
def getStepMetadata
def listStepMetadata
def generateXML
def getStep
def unregisterStep
def clear
def parseXML

Static Public Attributes

tuple security = ClassSecurityInfo()
 RegistryParser = _ImportStepRegistryParser

Private Member Functions

def _computeTopologicalSort

Static Private Attributes

tuple _exportTemplate = PageTemplateFile( 'isrExport.xml', _xmldir )

Detailed Description

Manage knowledge about steps to create / configure site.

o Steps are composed together to define a site profile.

Definition at line 325 of file registry.py.


Member Function Documentation

Definition at line 447 of file registry.py.

00447 
00448     def _computeTopologicalSort( self ):
00449         return _computeTopologicalSort(self._registered.values())
00450 

Here is the caller graph for this function:

Return a sequence of ( node, edge ) tuples for unsatisifed deps.

Definition at line 348 of file registry.py.

00348 
00349     def checkComplete( self ):
00350 
00351         """ Return a sequence of ( node, edge ) tuples for unsatisifed deps.
00352         """
00353         result = []
00354         seen = {}
00355 
00356         graph = self._computeTopologicalSort()
00357 
00358         for node in graph:
00359 
00360             dependencies = self.getStepMetadata( node )[ 'dependencies' ]
00361 
00362             for dependency in dependencies:
00363 
00364                 if seen.get( dependency ) is None:
00365                     result.append( ( node, dependency ) )
00366 
00367             seen[ node ] = 1
00368 
00369         return result

Here is the call graph for this function:

Definition at line 305 of file registry.py.

00305 
00306     def clear( self ):
00307 
00308         self._registered = {}

Here is the caller graph for this function:

Return a round-trippable XML representation of the registry.

o 'handler' values are serialized using their dotted names.

Definition at line 277 of file registry.py.

00277 
00278     def generateXML( self ):
00279 
00280         """ Return a round-trippable XML representation of the registry.
00281 
00282         o 'handler' values are serialized using their dotted names.
00283         """
00284         return self._exportTemplate()

def GenericSetup.registry.BaseStepRegistry.getStep (   self,
  key,
  default = None 
) [inherited]
Return the I(Export|Import)Plugin registered for 'key'.

o Return 'default' if no such step is registered.

Definition at line 286 of file registry.py.

00286 
00287     def getStep( self, key, default=None ):
00288 
00289         """ Return the I(Export|Import)Plugin registered for 'key'.
00290 
00291         o Return 'default' if no such step is registered.
00292         """
00293         marker = object()
00294         info = self._registered.get( key, marker )
00295 
00296         if info is marker:
00297             return default
00298 
00299         return _resolveDottedName( info[ 'handler' ] )

Here is the call graph for this function:

def GenericSetup.registry.BaseStepRegistry.getStepMetadata (   self,
  key,
  default = None 
) [inherited]
Return a mapping of metadata for the step identified by 'key'.

o Return 'default' if no such step is registered.

o The 'handler' metadata is available via 'getStep'.

Definition at line 245 of file registry.py.

00245 
00246     def getStepMetadata( self, key, default=None ):
00247 
00248         """ Return a mapping of metadata for the step identified by 'key'.
00249 
00250         o Return 'default' if no such step is registered.
00251 
00252         o The 'handler' metadata is available via 'getStep'.
00253         """
00254         result = {}
00255 
00256         info = self._registered.get( key )
00257 
00258         if info is None:
00259             return default
00260 
00261         result = info.copy()
00262         result['invalid'] =  _resolveDottedName( result[ 'handler' ] ) is None
00263 
00264         return result

Here is the call graph for this function:

Here is the caller graph for this function:

Return a sequence of mappings describing registered steps.

o Mappings will be ordered alphabetically.

Definition at line 266 of file registry.py.

00266 
00267     def listStepMetadata( self ):
00268 
00269         """ Return a sequence of mappings describing registered steps.
00270 
00271         o Mappings will be ordered alphabetically.
00272         """
00273         step_ids = self.listSteps()
00274         step_ids.sort()
00275         return [ self.getStepMetadata( x ) for x in step_ids ]

Here is the call graph for this function:

Return a list of registered step IDs.

Definition at line 238 of file registry.py.

00238 
00239     def listSteps( self ):
00240 
00241         """ Return a list of registered step IDs.
00242         """
00243         return self._registered.keys()

Here is the caller graph for this function:

def GenericSetup.registry.BaseStepRegistry.parseXML (   self,
  text,
  encoding = None 
) [inherited]
Parse 'text'.

Definition at line 310 of file registry.py.

00310 
00311     def parseXML( self, text, encoding=None ):
00312 
00313         """ Parse 'text'.
00314         """
00315         reader = getattr( text, 'read', None )
00316 
00317         if reader is not None:
00318             text = reader()
00319 
00320         parser = self.RegistryParser( encoding )
00321         parseString( text, parser )
00322 
00323         return parser._parsed
00324 InitializeClass( BaseStepRegistry )

Here is the caller graph for this function:

def GenericSetup.registry.ImportStepRegistry.registerStep (   self,
  id,
  version = None,
  handler = None,
  dependencies = (),
  title = None,
  description = None 
)
Register a setup step.

o 'id' is a unique name for this step,

o 'version' is a string for comparing versions, it is preferred to
  be a yyyy/mm/dd-ii formatted string (date plus two-digit
  ordinal).  when comparing two version strings, the version with
  the lower sort order is considered the older version.

  - Newer versions of a step supplant older ones.

  - Attempting to register an older one after a newer one results
    in a KeyError.

o 'handler' is the dottoed name of a handler which should implement
   IImportPlugin.

o 'dependencies' is a tuple of step ids which have to run before
  this step in order to be able to run at all. Registration of
  steps that have unmet dependencies are deferred until the
  dependencies have been registered.

o 'title' is a one-line UI description for this step.
  If None, the first line of the documentation string of the handler
  is used, or the id if no docstring can be found.

o 'description' is a one-line UI description for this step.
  If None, the remaining line of the documentation string of
  the handler is used, or default to ''.

Definition at line 378 of file registry.py.

00378 
00379                     ):
00380         """ Register a setup step.
00381 
00382         o 'id' is a unique name for this step,
00383 
00384         o 'version' is a string for comparing versions, it is preferred to
00385           be a yyyy/mm/dd-ii formatted string (date plus two-digit
00386           ordinal).  when comparing two version strings, the version with
00387           the lower sort order is considered the older version.
00388 
00389           - Newer versions of a step supplant older ones.
00390 
00391           - Attempting to register an older one after a newer one results
00392             in a KeyError.
00393 
00394         o 'handler' is the dottoed name of a handler which should implement
00395            IImportPlugin.
00396 
00397         o 'dependencies' is a tuple of step ids which have to run before
00398           this step in order to be able to run at all. Registration of
00399           steps that have unmet dependencies are deferred until the
00400           dependencies have been registered.
00401 
00402         o 'title' is a one-line UI description for this step.
00403           If None, the first line of the documentation string of the handler
00404           is used, or the id if no docstring can be found.
00405 
00406         o 'description' is a one-line UI description for this step.
00407           If None, the remaining line of the documentation string of
00408           the handler is used, or default to ''.
00409         """
00410         already = self.getStepMetadata( id )
00411 
00412         if handler is None:
00413             raise ValueError, 'No handler specified'
00414 
00415         if already and already[ 'version' ] > version:
00416             raise KeyError( 'Existing registration for step %s, version %s'
00417                           % ( id, already[ 'version' ] ) )
00418 
00419         if not isinstance(handler, str):
00420             handler = _getDottedName( handler )
00421 
00422         if title is None or description is None:
00423 
00424             method = _resolveDottedName(handler)
00425             if method is None:
00426                 t,d = id, ''
00427             else:
00428                 t, d = _extractDocstring( method, id, '' )
00429 
00430             title = title or t
00431             description = description or d
00432 
00433         info = { 'id'           : id
00434                , 'version'      : version
00435                , 'handler'      : handler
00436                , 'dependencies' : dependencies
00437                , 'title'        : title
00438                , 'description'  : description
00439                }
00440 
00441         self._registered[ id ] = info
00442 

Here is the call graph for this function:

Here is the caller graph for this function:

Return a sequence of registered step IDs

o Sequence is sorted topologically by dependency, with the dependent
  steps *after* the steps they depend on.

Definition at line 338 of file registry.py.

00338 
00339     def sortSteps( self ):
00340 
00341         """ Return a sequence of registered step IDs
00342 
00343         o Sequence is sorted topologically by dependency, with the dependent
00344           steps *after* the steps they depend on.
00345         """
00346         return self._computeTopologicalSort()

Here is the call graph for this function:

def GenericSetup.registry.BaseStepRegistry.unregisterStep (   self,
  id 
) [inherited]

Definition at line 301 of file registry.py.

00301 
00302     def unregisterStep( self, id ):
00303         del self._registered[id]


Member Data Documentation

tuple GenericSetup.registry.ImportStepRegistry._exportTemplate = PageTemplateFile( 'isrExport.xml', _xmldir ) [static, private]

Definition at line 452 of file registry.py.

Definition at line 334 of file registry.py.

tuple GenericSetup.registry.ImportStepRegistry.security = ClassSecurityInfo() [static]

Reimplemented from GenericSetup.registry.BaseStepRegistry.

Definition at line 333 of file registry.py.


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