[CMF-checkins] CVS: CMF/CMFSetup - __init__.py:1.8.2.2
factory.py:1.3.2.2 interfaces.py:1.16.2.3
registry.py:1.18.2.1 tool.py:1.18.2.4
Yvo Schubbe
y.2005- at wcm-solutions.de
Tue Apr 5 11:17:48 EDT 2005
Update of /cvs-repository/CMF/CMFSetup
In directory cvs.zope.org:/tmp/cvs-serv8223/CMFSetup
Modified Files:
Tag: CMF-1_5-branch
__init__.py factory.py interfaces.py registry.py tool.py
Log Message:
backported recent CMFSetup changes from HEAD to CMF-1_5-branch
=== CMF/CMFSetup/__init__.py 1.8.2.1 => 1.8.2.2 ===
--- CMF/CMFSetup/__init__.py:1.8.2.1 Sun Nov 28 15:05:55 2004
+++ CMF/CMFSetup/__init__.py Tue Apr 5 11:17:16 2005
@@ -17,6 +17,7 @@
from AccessControl import ModuleSecurityInfo
+from interfaces import BASE, EXTENSION
from permissions import ManagePortal
from registry import _profile_registry as profile_registry
=== CMF/CMFSetup/factory.py 1.3.2.1 => 1.3.2.2 ===
--- CMF/CMFSetup/factory.py:1.3.2.1 Thu Jan 20 13:59:35 2005
+++ CMF/CMFSetup/factory.py Tue Apr 5 11:17:16 2005
@@ -20,6 +20,7 @@
from Products.CMFCore.utils import getToolByName
from Products.CMFDefault.Portal import CMFSite
+from interfaces import EXTENSION
from registry import _profile_registry as profile_registry
from tool import SetupTool
from utils import _wwwdir
@@ -30,9 +31,25 @@
"""
wrapped = PageTemplateFile( 'siteAddForm', _wwwdir ).__of__( dispatcher )
- return wrapped( profiles=profile_registry.listProfileInfo() )
+ base_profiles = []
+ extension_profiles = []
-def addConfiguredSite( dispatcher, site_id, profile_id, RESPONSE=None ):
+ for info in profile_registry.listProfileInfo():
+ if info.get('type') == EXTENSION:
+ extension_profiles.append(info)
+ else:
+ base_profiles.append(info)
+
+ return wrapped( base_profiles=tuple(base_profiles),
+ extension_profiles =tuple(extension_profiles) )
+
+def addConfiguredSite( dispatcher
+ , site_id
+ , profile_id
+ , snapshot=True
+ , RESPONSE=None
+ , extension_ids=()
+ ):
""" Add a CMFSite to 'dispatcher', configured according to 'profile_id'.
"""
@@ -46,7 +63,13 @@
setup_tool.setImportContext( 'profile-%s' % profile_id )
setup_tool.runAllImportSteps()
- setup_tool.createSnapshot( 'initial_configuration' )
+ for extension_id in extension_ids:
+ setup_tool.setImportContext( 'profile-%s' % extension_id )
+ setup_tool.runAllImportSteps()
+ setup_tool.setImportContext( 'profile-%s' % profile_id )
+
+ if snapshot is True:
+ setup_tool.createSnapshot( 'initial_configuration' )
if RESPONSE is not None:
RESPONSE.redirect( '%s/manage_main?update_menu=1'
=== CMF/CMFSetup/interfaces.py 1.16.2.2 => 1.16.2.3 ===
--- CMF/CMFSetup/interfaces.py:1.16.2.2 Thu Jan 20 13:59:35 2005
+++ CMF/CMFSetup/interfaces.py Tue Apr 5 11:17:16 2005
@@ -17,6 +17,10 @@
from Interface import Interface
+
+BASE, EXTENSION = range(2)
+
+
class IPseudoInterface( Interface ):
""" API documentation; not testable / enforceable.
@@ -178,7 +182,7 @@
def parseXML( text ):
- """ Parse 'text' into a clean registry.
+ """ Parse 'text'.
"""
class IImportStepRegistry( IStepRegistry ):
@@ -344,6 +348,8 @@
'product' -- the name of the product to which 'path' is
relative (None for absolute paths).
+
+ 'type' -- either BASE or EXTENSION
"""
def listProfiles():
@@ -358,15 +364,16 @@
o See 'getProfileInfo' for a description of the mappings' keys.
"""
- def registerProfile( profile_id
+ def registerProfile( name
, title
, description
, path
, product=None
+ , profile_type=BASE
):
- """ Add a new profile to tne registry.
+ """ Add a new profile to the registry.
- o If an existing profile is already registered for 'profile_id',
+ o If an existing profile is already registered for 'product:name',
raise KeyError.
o If 'product' is passed, then 'path' should be interpreted as
@@ -410,7 +417,7 @@
""" Return the IToolsetRegistry for the tool.
"""
- def runImportStep( step_id, purge_old=True, run_dependencies=True ):
+ def runImportStep( step_id, run_dependencies=True, purge_old=None ):
""" Execute a given setup step
@@ -431,7 +438,7 @@
step
"""
- def runAllImportSteps( purge_old=True ):
+ def runAllImportSteps( purge_old=None ):
""" Run all setup steps in dependency order.
=== CMF/CMFSetup/registry.py 1.18 => 1.18.2.1 ===
--- CMF/CMFSetup/registry.py:1.18 Thu Aug 12 11:07:41 2004
+++ CMF/CMFSetup/registry.py Tue Apr 5 11:17:16 2005
@@ -22,6 +22,7 @@
from Globals import InitializeClass
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
+from interfaces import BASE
from interfaces import IImportStepRegistry
from interfaces import IExportStepRegistry
from interfaces import IToolsetRegistry
@@ -33,6 +34,7 @@
from utils import _resolveDottedName
from utils import _extractDocstring
+
class ImportStepRegistry( Implicit ):
""" Manage knowledge about steps to create / configure site.
@@ -45,7 +47,7 @@
def __init__( self ):
- self._clear()
+ self.clear()
security.declareProtected( ManagePortal, 'listSteps' )
def listSteps( self ):
@@ -182,7 +184,7 @@
"""
already = self.getStepMetadata( id )
- if already and already[ 'version' ] >= version:
+ if already and already[ 'version' ] > version:
raise KeyError( 'Existing registration for step %s, version %s'
% ( id, already[ 'version' ] ) )
@@ -206,10 +208,8 @@
security.declarePrivate( 'parseXML' )
def parseXML( self, text, encoding=None ):
- """ Parse 'text' into a clean registry.
+ """ Parse 'text'.
"""
- self._clear()
-
reader = getattr( text, 'read', None )
if reader is not None:
@@ -220,14 +220,14 @@
return parser._parsed
- #
- # Helper methods
- #
- security.declarePrivate( '_clear' )
- def _clear( self ):
+ security.declarePrivate( 'clear' )
+ def clear( self ):
self._registered = {}
+ #
+ # Helper methods
+ #
security.declarePrivate( '_computeTopologicalSort' )
def _computeTopologicalSort( self ):
@@ -279,7 +279,7 @@
def __init__( self ):
- self._registered = {}
+ self.clear()
security.declareProtected( ManagePortal, 'listSteps' )
def listSteps( self ):
@@ -356,11 +356,6 @@
If None, the remaining line of the documentation string of
the step is used, or default to ''.
"""
- already = self.getStep( id )
-
- if already:
- raise KeyError( 'Existing registration for step %s' % id )
-
if title is None or description is None:
t, d = _extractDocstring( handler, id, '' )
@@ -379,10 +374,8 @@
security.declarePrivate( 'parseXML' )
def parseXML( self, text, encoding=None ):
- """ Parse 'text' into a clean registry.
+ """ Parse 'text'.
"""
- self._clear()
-
reader = getattr( text, 'read', None )
if reader is not None:
@@ -393,14 +386,14 @@
return parser._parsed
- #
- # Helper methods
- #
- security.declarePrivate( '_clear' )
- def _clear( self ):
+ security.declarePrivate( 'clear' )
+ def clear( self ):
self._registered = {}
+ #
+ # Helper methods
+ #
security.declarePrivate( '_exportTemplate' )
_exportTemplate = PageTemplateFile( 'esrExport.xml', _xmldir )
@@ -417,7 +410,7 @@
def __init__( self ):
- self._clear()
+ self.clear()
#
# Toolset API
@@ -437,7 +430,7 @@
""" See IToolsetRegistry.
"""
if tool_id in self._forbidden:
- raise KeyError, 'Duplicate forbidden tool: %s' % tool_id
+ return
if self._required.get( tool_id ) is not None:
raise ValueError, 'Tool %s is required!' % tool_id
@@ -473,9 +466,6 @@
""" See IToolsetRegistry.
"""
- if self._required.get( tool_id ) is not None:
- raise KeyError, "Duplicate required tool: %s" % tool_id
-
if tool_id in self._forbidden:
raise ValueError, "Forbidden tool ID: %s" % tool_id
@@ -503,23 +493,21 @@
parser = _ToolsetParser( encoding )
parseString( text, parser )
- self._clear()
-
for tool_id in parser._forbidden:
self.addForbiddenTool( tool_id )
for tool_id, dotted_name in parser._required.items():
self.addRequiredTool( tool_id, dotted_name )
- #
- # Helper methods.
- #
- security.declarePrivate( '_clear' )
- def _clear( self ):
+ security.declarePrivate( 'clear' )
+ def clear( self ):
self._forbidden = []
self._required = {}
+ #
+ # Helper methods.
+ #
security.declarePrivate( '_toolsetConfig' )
_toolsetConfig = PageTemplateFile( 'tscExport.xml'
, _xmldir
@@ -539,7 +527,7 @@
def __init__( self ):
- self._clear()
+ self.clear()
security.declareProtected( ManagePortal, '' )
def getProfileInfo( self, profile_id ):
@@ -565,14 +553,16 @@
security.declareProtected( ManagePortal, 'registerProfile' )
def registerProfile( self
- , profile_id
+ , name
, title
, description
, path
, product=None
+ , profile_type=BASE
):
""" See IProfileRegistry.
"""
+ profile_id = '%s:%s' % (product or 'other', name)
if self._profile_info.get( profile_id ) is not None:
raise KeyError, 'Duplicate profile ID: %s' % profile_id
@@ -583,13 +573,13 @@
, 'description' : description
, 'path' : path
, 'product' : product
+ , 'type': profile_type
}
self._profile_info[ profile_id ] = info
- # Helper methods
- security.declarePrivate( '_clear' )
- def _clear( self ):
+ security.declarePrivate( 'clear' )
+ def clear( self ):
self._profile_info = {}
self._profile_ids = []
=== CMF/CMFSetup/tool.py 1.18.2.3 => 1.18.2.4 ===
--- CMF/CMFSetup/tool.py:1.18.2.3 Thu Jan 20 13:59:35 2005
+++ CMF/CMFSetup/tool.py Tue Apr 5 11:17:16 2005
@@ -28,6 +28,7 @@
from Products.CMFCore.utils import UniqueObject
from Products.CMFCore.utils import getToolByName
+from interfaces import EXTENSION
from interfaces import ISetupTool
from permissions import ManagePortal
from context import DirectoryImportContext
@@ -188,7 +189,7 @@
return self._toolset_registry
security.declareProtected( ManagePortal, 'executeStep' )
- def runImportStep( self, step_id, run_dependencies=True, purge_old=True ):
+ def runImportStep( self, step_id, run_dependencies=True, purge_old=None ):
""" See ISetupTool.
"""
@@ -218,7 +219,7 @@
return { 'steps' : steps, 'messages' : messages }
security.declareProtected( ManagePortal, 'runAllSetupSteps')
- def runAllImportSteps( self, purge_old=True ):
+ def runAllImportSteps( self, purge_old=None ):
""" See ISetupTool.
"""
@@ -382,7 +383,6 @@
def manage_importSelectedSteps( self
, ids
, run_dependencies
- , purge_old
, RESPONSE
):
""" Import the steps selected by the user.
@@ -393,10 +393,7 @@
else:
steps_run = []
for step_id in ids:
- result = self.runImportStep( step_id
- , run_dependencies
- , purge_old
- )
+ result = self.runImportStep( step_id, run_dependencies )
steps_run.extend( result[ 'steps' ] )
message = 'Steps+run:%s' % '+,'.join( steps_run )
@@ -406,11 +403,11 @@
)
security.declareProtected( ManagePortal, 'manage_importSelectedSteps' )
- def manage_importAllSteps( self, purge_old, RESPONSE ):
+ def manage_importAllSteps( self, RESPONSE ):
""" Import all steps.
"""
- result = self.runAllImportSteps( purge_old )
+ result = self.runAllImportSteps()
message = 'Steps+run:%s' % '+,'.join( result[ 'steps' ] )
RESPONSE.redirect( '%s/manage_importSteps?manage_tabs_message=%s'
@@ -586,7 +583,7 @@
return product.__path__[0]
security.declarePrivate( '_getImportContext' )
- def _getImportContext( self, context_id, should_purge=False ):
+ def _getImportContext( self, context_id, should_purge=None ):
""" Crack ID and generate appropriate import context.
"""
@@ -602,11 +599,14 @@
, info[ 'path' ] )
else:
path = info[ 'path' ]
-
+ if should_purge is None:
+ should_purge = (info.get('type') != EXTENSION)
return DirectoryImportContext(self, path, should_purge, encoding)
# else snapshot
context_id = context_id[ len( 'snapshot-' ): ]
+ if should_purge is None:
+ should_purge = True
return SnapshotImportContext(self, context_id, should_purge, encoding)
security.declarePrivate( '_updateImportStepsRegistry' )
@@ -616,6 +616,8 @@
"""
context = self._getImportContext(self._import_context_id)
xml = context.readDataFile(IMPORT_STEPS_XML)
+ if xml is None:
+ return
info_list = self._import_registry.parseXML( xml, encoding )
@@ -644,6 +646,8 @@
"""
context = self._getImportContext(self._import_context_id)
xml = context.readDataFile(EXPORT_STEPS_XML)
+ if xml is None:
+ return
info_list = self._export_registry.parseXML( xml, encoding )
@@ -668,6 +672,8 @@
"""
context = self._getImportContext(self._import_context_id)
xml = context.readDataFile(TOOLSET_XML)
+ if xml is None:
+ return
self._toolset_registry.parseXML( xml, encoding )
More information about the CMF-checkins
mailing list