[CMF-checkins] CVS: CMF/CMFSetup - __init__.py:1.4
interfaces.py:1.11 registry.py:1.15
Tres Seaver
tseaver at zope.com
Thu Jul 1 14:42:23 EDT 2004
Update of /cvs-repository/CMF/CMFSetup
In directory cvs.zope.org:/tmp/cvs-serv23575
Modified Files:
__init__.py interfaces.py registry.py
Log Message:
- Add a global 'profile_registry', to allow third-party products to
register profiles.
=== CMF/CMFSetup/__init__.py 1.3 => 1.4 ===
--- CMF/CMFSetup/__init__.py:1.3 Mon May 24 10:36:48 2004
+++ CMF/CMFSetup/__init__.py Thu Jul 1 14:41:53 2004
@@ -2,13 +2,13 @@
$Id$
"""
+from AccessControl import ModuleSecurityInfo
-#
-# Export API for third-party products (XXX: not yet!)
-#
-#from SiteConfiguration import registerSetupStep
-#from SiteConfiguration import registerExportScript
+from permissions import ManagePortal
+from registry import _profile_registry as profile_registry
+security = ModuleSecurityInfo( 'Products.CMFSetup' )
+security.declareProtected( ManagePortal, 'profile_registry' )
def initialize(context):
@@ -83,38 +83,11 @@
))
registerExportScript('generateSkeleton', generateSkeleton)
- from ActionsConfig import configureToolGeneratedActions
- from ActionsConfig import exportToolGeneratedActions
-
- registerSetupStep('configureToolGeneratedActions', '2004/05/10-01',
- configureToolGeneratedActions)
- registerExportScript('exportToolGeneratedActions',
- exportToolGeneratedActions)
-
- from ContentTypesConfig import installTypes, exportTypes
- registerSetupStep('installTypes', '2004/05/10-01', installTypes)
- registerExportScript('exportTypes', exportTypes)
-
from ActionIconsConfig import configureActionIcons, exportActionIcons
registerSetupStep('configureActionIcons', '2004/05/10-02',
configureActionIcons, ('installTools',))
registerExportScript('exportActionIcons', exportActionIcons)
- from SkinsConfig import configureSkins, exportSkins
- registerSetupStep('configureSkins', '2004/05/10-01', configureSkins)
- registerExportScript('exportSkins', exportSkins)
-
- from WorkflowConfig import configureWorkflows, exportWorkflows
- registerSetupStep('configureWorkflows', '2004/05/10-01',
- configureWorkflows, ('installTypes',))
- registerExportScript('exportWorkflows', exportWorkflows)
-
- from RolesPermissionsConfig import configureRolesPermissions
- from RolesPermissionsConfig import exportRolesPermissions
- registerSetupStep('configureRolesPermissions', '2004/05/10-01',
- configureRolesPermissions)
- registerExportScript('exportRolesPermissions', exportRolesPermissions)
-
from MembershipConfig import installMembershipToolContent
from MembershipConfig import exportMembershipToolContent
registerSetupStep('installMembershipToolContent', '2004/05/10-01',
@@ -122,10 +95,6 @@
'installTypes'))
registerExportScript('exportMembershipToolContent',
exportMembershipToolContent)
-
- from RemoveTools import removeInstalledTools
- registerSetupStep('removeInstalledTools', '2004/05/10-1',
- removeInstalledTools, ('installTools',))
from MemberDataConfig import configureMemberDataTool
from MemberDataConfig import exportMemberDataToolConfig
=== CMF/CMFSetup/interfaces.py 1.10 => 1.11 ===
--- CMF/CMFSetup/interfaces.py:1.10 Wed Jun 30 14:12:59 2004
+++ CMF/CMFSetup/interfaces.py Thu Jul 1 14:41:53 2004
@@ -310,6 +310,48 @@
o Raise ValueError if 'tool_id' is in the "forbidden" list.
"""
+class IProfileRegistry( Interface ):
+
+ """ API for profile registry.
+ """
+ def getProfileInfo( profile_id ):
+
+ """ Return a mapping describing a registered filesystem profile.
+
+ o Keys include:
+
+ 'id' -- the ID of the profile
+
+ 'title' -- its title
+
+ 'description' -- a textual description of the profile
+
+ 'path' -- a path to the profile on the filesystem.
+ """
+
+ def listProfiles():
+
+ """ Return a list of IDs for registered profiles.
+ """
+
+ def listProfileInfo():
+
+ """ Return a list of mappings describing registered profiles.
+
+ o See 'getProfileInfo' for a description of the mappings' keys.
+ """
+
+ def registerProfile( profile_id
+ , title
+ , description
+ , path
+ ):
+ """ Add a new profile to tne registry.
+
+ o If an existing profile is already registered for 'profile_id',
+ raise KeyError.
+ """
+
class ISetupTool( Interface ):
""" API for SetupTool.
=== CMF/CMFSetup/registry.py 1.14 => 1.15 ===
--- CMF/CMFSetup/registry.py:1.14 Wed Jun 30 14:58:51 2004
+++ CMF/CMFSetup/registry.py Thu Jul 1 14:41:53 2004
@@ -14,6 +14,7 @@
from interfaces import IImportStepRegistry
from interfaces import IExportStepRegistry
from interfaces import IToolsetRegistry
+from interfaces import IProfileRegistry
from permissions import ManagePortal
from utils import HandlerBase
from utils import _xmldir
@@ -516,6 +517,91 @@
InitializeClass( ToolsetRegistry )
+class ProfileRegistry( Implicit ):
+
+ """ Track registered profiles.
+ """
+ __implements__ = ( IProfileRegistry, )
+
+ security = ClassSecurityInfo()
+ security.setDefaultAccess( 'allow' )
+
+ def __init__( self ):
+
+ self._clear()
+
+ security.declareProtected( ManagePortal, '' )
+ def getProfileInfo( self, profile_id ):
+
+ """ Return a mapping describing a registered profile.
+
+ o Keys include:
+
+ 'id' -- the ID of the profile
+
+ 'title' -- its title
+
+ 'description' -- a textual description of the profile
+
+ 'type' -- 'FILESYSTEM' or 'SNAPSHOT'
+
+ 'path' -- a path to the profile (either within the ZODB, for
+ snapshots, or on the filesystem).
+ """
+ result = self._profile_info[ profile_id ]
+ return result.copy()
+
+ security.declareProtected( ManagePortal, 'listProfiles' )
+ def listProfiles( self ):
+
+ """ Return a list of IDs for registered profiles.
+ """
+ return tuple( self._profile_ids )
+
+ security.declareProtected( ManagePortal, 'listProfileInfo' )
+ def listProfileInfo( self ):
+
+ """ Return a list of mappings describing registered profiles.
+
+ o See 'getProfileInfo' for a description of the mappings' keys.
+ """
+ return [ self.getProfileInfo( id ) for id in self.listProfiles() ]
+
+ security.declareProtected( ManagePortal, 'registerProfile' )
+ def registerProfile( self
+ , profile_id
+ , title
+ , description
+ , path
+ ):
+ """ Add a new profile to tne registry.
+
+ o If an existing profile is already registered for 'profile_id',
+ raise KeyError.
+ """
+ if self._profile_info.get( profile_id ) is not None:
+ raise KeyError, 'Duplicate profile ID: %s' % profile_id
+
+ self._profile_ids.append( profile_id )
+
+ info = { 'id' : profile_id
+ , 'title' : title
+ , 'description' : description
+ , 'path' : path
+ }
+
+ self._profile_info[ profile_id ] = info
+
+ # Helper methods
+ security.declarePrivate( '_clear' )
+ def _clear( self ):
+
+ self._profile_info = {}
+ self._profile_ids = []
+
+InitializeClass( ProfileRegistry )
+
+_profile_registry = ProfileRegistry()
class _ImportStepRegistryParser( HandlerBase ):
More information about the CMF-checkins
mailing list