Back to index

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

List of all members.

Public Member Functions

def __init__
def getProfileInfo
def listProfiles
def listProfileInfo
def registerProfile
def clear

Static Public Attributes

tuple security = ClassSecurityInfo()

Private Attributes

 _profile_info
 _profile_ids

Detailed Description

Track registered profiles.

Definition at line 651 of file registry.py.


Constructor & Destructor Documentation

Definition at line 660 of file registry.py.

00660 
00661     def __init__( self ):
00662 
00663         self.clear()

Here is the call graph for this function:


Member Function Documentation

Definition at line 758 of file registry.py.

00758 
00759     def clear( self ):
00760 
00761         self._profile_info = {}
00762         self._profile_ids = []
00763 
00764 InitializeClass( ProfileRegistry )

Here is the caller graph for this function:

def GenericSetup.registry.ProfileRegistry.getProfileInfo (   self,
  profile_id,
  for_ = None 
)
See IProfileRegistry.

Definition at line 665 of file registry.py.

00665 
00666     def getProfileInfo( self, profile_id, for_=None ):
00667 
00668         """ See IProfileRegistry.
00669         """
00670         result = self._profile_info[ profile_id ]
00671         if for_ is not None:
00672             if not issubclass( for_, result['for'] ):
00673                 raise KeyError, profile_id
00674         return result.copy()

Here is the caller graph for this function:

def GenericSetup.registry.ProfileRegistry.listProfileInfo (   self,
  for_ = None 
)
See IProfileRegistry.

Definition at line 688 of file registry.py.

00688 
00689     def listProfileInfo( self, for_=None ):
00690 
00691         """ See IProfileRegistry.
00692         """
00693         candidates = [ self.getProfileInfo( id )
00694                         for id in self.listProfiles() ]
00695         return [ x for x in candidates if for_ is None or x['for'] is None or
00696                  issubclass( for_, x['for'] ) ]

Here is the call graph for this function:

Here is the caller graph for this function:

def GenericSetup.registry.ProfileRegistry.listProfiles (   self,
  for_ = None 
)
See IProfileRegistry.

Definition at line 676 of file registry.py.

00676 
00677     def listProfiles( self, for_=None ):
00678 
00679         """ See IProfileRegistry.
00680         """
00681         result = []
00682         for profile_id in self._profile_ids:
00683             info = self.getProfileInfo( profile_id )
00684             if for_ is None or issubclass( for_, info['for'] ):
00685                 result.append( profile_id )
00686         return tuple( result )

Here is the call graph for this function:

Here is the caller graph for this function:

def GenericSetup.registry.ProfileRegistry.registerProfile (   self,
  name,
  title,
  description,
  path,
  product = None,
  profile_type = BASE,
  for_ = None 
)
See IProfileRegistry.

Definition at line 706 of file registry.py.

00706 
00707                        ):
00708         """ See IProfileRegistry.
00709         """
00710         profile_id = '%s:%s' % (product or 'other', name)
00711         if self._profile_info.get( profile_id ) is not None:
00712             raise KeyError, 'Duplicate profile ID: %s' % profile_id
00713 
00714         self._profile_ids.append( profile_id )
00715 
00716         info = { 'id' : profile_id
00717                , 'title' : title
00718                , 'description' : description
00719                , 'path' : path
00720                , 'product' : product
00721                , 'type': profile_type
00722                , 'for': for_
00723                }
00724 
00725         metadata = ProfileMetadata(path, product=product)()
00726 
00727         version = metadata.get( 'version', None )
00728         if version is None and product is not None:
00729             prod_name = product.split('.')[-1]
00730             prod_module = getattr(App.Product.Products, prod_name, None)
00731             if prod_module is not None:
00732                 prod_path = prod_module.__path__[0]
00733 
00734                 # Retrieve version number from any suitable version.txt
00735                 for fname in ('version.txt', 'VERSION.txt', 'VERSION.TXT'):
00736                     try:
00737                         fpath = os.path.join( prod_path, fname )
00738                         fhandle = open( fpath, 'r' )
00739                         version = fhandle.read().strip()
00740                         fhandle.close()
00741                         warn('Version for profile %s taken from version.txt. '
00742                              'This is deprecated behaviour and will be '
00743                              'removed in GenericSetup 1.5: please specify '
00744                              'the version in metadata.xml.' % profile_id,
00745                              DeprecationWarning)
00746                         break
00747                     except IOError:
00748                         continue
00749 
00750             if version is not None:
00751                 metadata[ 'version' ] = version
00752 
00753         # metadata.xml description trumps ZCML description... awkward
00754         info.update( metadata )
00755 
00756         self._profile_info[ profile_id ] = info

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 761 of file registry.py.

Definition at line 760 of file registry.py.

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

Definition at line 657 of file registry.py.


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