[CMF-checkins] CVS: CMF/CMFSetup - README.txt:1.11 factory.py:1.4 interfaces.py:1.18 tool.py:1.21

Yvo Schubbe y.2005- at wcm-solutions.de
Thu Jan 20 14:00:49 EST 2005


Update of /cvs-repository/CMF/CMFSetup
In directory cvs.zope.org:/tmp/cvs-serv8679/CMFSetup

Modified Files:
	README.txt factory.py interfaces.py tool.py 
Log Message:
- made configuration selectable from a list of registered profiles and stored snapshots (http://collector.zope.org/CMF/264)
- removed getProfileProduct, getProfileDirectory and setProfileDirectory
- added getImportContextId and setImportContext
- synced parts of sutCompare.zpt with sutProperties.zpt


=== CMF/CMFSetup/README.txt 1.10 => 1.11 ===
--- CMF/CMFSetup/README.txt:1.10	Fri Dec 17 12:51:10 2004
+++ CMF/CMFSetup/README.txt	Thu Jan 20 14:00:19 2005
@@ -99,10 +99,10 @@
       - (x) Display / download diffs between configurations (profiles
             and shapshots) Done 2004/07/20, TS.
 
-      - (_) Modify profile selection to use a drop-down list of registered
+      - (x) Modify profile selection to use a drop-down list of registered
             profiles.
 
-      - (_) Allow import from snapshots.
+      - (x) Allow import from snapshots.
 
   Extending The Tool
 


=== CMF/CMFSetup/factory.py 1.3 => 1.4 ===
--- CMF/CMFSetup/factory.py:1.3	Thu Aug 12 11:07:41 2004
+++ CMF/CMFSetup/factory.py	Thu Jan 20 14:00:19 2005
@@ -44,11 +44,7 @@
     site._setObject( 'portal_setup', setup_tool )
     setup_tool = getToolByName( site, 'portal_setup' )
 
-    profile_info = profile_registry.getProfileInfo( profile_id )
-    setup_tool.setProfileDirectory( profile_info[ 'path' ]
-                                  , profile_info.get( 'product' )
-                                  )
-
+    setup_tool.setImportContext( 'profile-%s' % profile_id )
     setup_tool.runAllImportSteps()
     setup_tool.createSnapshot( 'initial_configuration' )
 


=== CMF/CMFSetup/interfaces.py 1.17 => 1.18 ===
--- CMF/CMFSetup/interfaces.py:1.17	Mon Oct 11 08:49:54 2004
+++ CMF/CMFSetup/interfaces.py	Thu Jan 20 14:00:19 2005
@@ -385,29 +385,14 @@
         o Return None if the data should not be encoded.
         """
 
-    def getProfileProduct():
+    def getImportContextID():
 
-        """ Return the name of the product defining our current profile.
-
-        o Return None if the current profile is not relative to a product.
+        """ Get the ID of the active import context.
         """
 
-    def getProfileDirectory( relative_to_product=False ):
-
-        """ Return the path to the directory containing profile information.
-
-        o If 'relative_to_product', return it relative to the root directory
-          of our profile product.
-        """
-
-    def setProfileDirectory( path, product_name=None ):
-
-        """ Set the path to the directory containing profile information.
-
-        o If 'product_name' is not None, compute the fully-qualified path
-          relative to the product's root directory.
+    def setImportContext( context_id ):
 
-        o Update the import and export step registries from that directory.
+        """ Set the ID of the active import context and update the registries.
         """
 
     def getImportStepRegistry():


=== CMF/CMFSetup/tool.py 1.20 => 1.21 ===
--- CMF/CMFSetup/tool.py:1.20	Mon Oct 11 08:49:54 2004
+++ CMF/CMFSetup/tool.py	Thu Jan 20 14:00:19 2005
@@ -124,9 +124,7 @@
     id = 'portal_setup'
     meta_type = 'Portal Setup Tool'
 
-    _product_name = None
-    _profile_directory = None
-    _root_directory = None
+    _import_context_id = ''
 
     security = ClassSecurityInfo()
 
@@ -150,43 +148,19 @@
         """
         return 'ascii'
 
-    security.declareProtected( ManagePortal, 'getProfileProduct' )
-    def getProfileProduct( self ):
+    security.declareProtected( ManagePortal, 'getImportContextId' )
+    def getImportContextID( self ):
 
         """ See ISetupTool.
         """
-        return self._product_name
+        return self._import_context_id
 
-    security.declareProtected( ManagePortal, 'getProfileDirectory' )
-    def getProfileDirectory( self, relative_to_product=False ):
+    security.declareProtected(ManagePortal, 'setImportContext')
+    def setImportContext(self, context_id, encoding=None):
 
         """ See ISetupTool.
         """
-        return ( relative_to_product
-             and self._profile_directory
-              or self._getFullyQualifiedProfileDirectory()
-               )
-
-    security.declareProtected( ManagePortal, 'setProfileDirectory' )
-    def setProfileDirectory( self, path, product_name=None, encoding=None ):
-
-        """ See ISetupTool.
-        """
-        if product_name is not None:
-
-            root = self._root_directory = self._getProductPath( product_name )
-
-            if not os.path.exists( os.path.join( root, path ) ):
-                raise ValueError, 'Invalid path: %s' % path
-
-        else:
-            if not os.path.exists( path ):
-                raise ValueError, 'Invalid path: %s' % path
-
-            self._root_directory = None
-
-        self._profile_directory = path
-        self._product_name = product_name
+        self._import_context_id = context_id
 
         self._updateImportStepsRegistry( encoding )
         self._updateExportStepsRegistry( encoding )
@@ -218,10 +192,7 @@
 
         """ See ISetupTool.
         """
-        profile_path = self._getFullyQualifiedProfileDirectory()
-        encoding = self.getEncoding()
-        context = DirectoryImportContext( self, profile_path, purge_old,
-                                          encoding )
+        context = self._getImportContext(self._import_context_id, purge_old)
 
         info = self._import_registry.getStepMetadata( step_id )
 
@@ -251,10 +222,7 @@
 
         """ See ISetupTool.
         """
-        profile_path = self._getFullyQualifiedProfileDirectory()
-        encoding = self.getEncoding()
-        context = DirectoryImportContext( self, profile_path, purge_old,
-                                          encoding )
+        context = self._getImportContext(self._import_context_id, purge_old)
 
         steps = self._import_registry.sortSteps()
         messages = {}
@@ -398,25 +366,10 @@
     manage_tool = PageTemplateFile( 'sutProperties', _wwwdir )
 
     security.declareProtected( ManagePortal, 'manage_updateToolProperties' )
-    def manage_updateToolProperties( self
-                                   , profile_directory
-                                   , profile_product
-                                   , RESPONSE
-                                   ):
+    def manage_updateToolProperties(self, context_id, RESPONSE):
         """ Update the tool's settings.
         """
-        profile_directory = profile_directory.strip()
-        profile_product = profile_product.strip()
-
-        if profile_directory.startswith( '.' ):
-            raise ValueError(
-                    "Directories begining with '.' are not allowed." )
-
-        if profile_product and profile_directory.startswith( '/' ):
-            raise ValueError(
-                    "Product may not be specified with absolute directories" )
-
-        self.setProfileDirectory( profile_directory, profile_product )
+        self.setImportContext(context_id)
 
         RESPONSE.redirect( '%s/manage_tool?manage_tabs_message=%s'
                          % ( self.absolute_url(), 'Properties+updated.' )
@@ -544,6 +497,21 @@
         """
         return _profile_registry.listProfileInfo()
 
+    security.declareProtected(ManagePortal, 'listContextInfos')
+    def listContextInfos(self):
+
+        """ List registered profiles and snapshots.
+        """
+
+        s_infos = [ { 'id': 'snapshot-%s' % info['id'],
+                      'title': info['title'] }
+                    for info in self.listSnapshotInfo() ]
+        p_infos = [ { 'id': 'profile-%s' % info['id'],
+                      'title': info['title'] }
+                    for info in self.listProfileInfo() ]
+
+        return tuple(s_infos + p_infos)
+
     security.declareProtected( ManagePortal, 'manage_createSnapshot' )
     def manage_createSnapshot( self, RESPONSE, snapshot_id=None ):
 
@@ -618,10 +586,12 @@
         return product.__path__[0]
 
     security.declarePrivate( '_getImportContext' )
-    def _getImportContext( self, context_id ):
+    def _getImportContext( self, context_id, should_purge=False ):
 
         """ Crack ID and generate appropriate import context.
         """
+        encoding = self.getEncoding()
+
         if context_id.startswith( 'profile-' ):
 
             context_id = context_id[ len( 'profile-' ): ]
@@ -633,33 +603,19 @@
             else:
                 path = info[ 'path' ]
 
-            return DirectoryImportContext( self, path )
+            return DirectoryImportContext(self, path, should_purge, encoding)
 
         # else snapshot
         context_id = context_id[ len( 'snapshot-' ): ]
-        return SnapshotImportContext( self, context_id )
-
-    security.declarePrivate( '_getFullyQualifiedProfileDirectory' )
-    def _getFullyQualifiedProfileDirectory( self ):
-
-        """ Return the fully-qualified directory path of our profile.
-        """
-        if self._root_directory is not None:
-            return os.path.join( self._root_directory
-                               , self._profile_directory )
-
-        return self._profile_directory
+        return SnapshotImportContext(self, context_id, should_purge, encoding)
 
     security.declarePrivate( '_updateImportStepsRegistry' )
     def _updateImportStepsRegistry( self, encoding ):
 
         """ Update our import steps registry from our profile.
         """
-        fq = self._getFullyQualifiedProfileDirectory()
-
-        f = open( os.path.join( fq, IMPORT_STEPS_XML ), 'r' )
-        xml = f.read()
-        f.close()
+        context = self._getImportContext(self._import_context_id)
+        xml = context.readDataFile(IMPORT_STEPS_XML)
 
         info_list = self._import_registry.parseXML( xml, encoding )
 
@@ -686,11 +642,8 @@
 
         """ Update our export steps registry from our profile.
         """
-        fq = self._getFullyQualifiedProfileDirectory()
-
-        f = open( os.path.join( fq, EXPORT_STEPS_XML ), 'r' )
-        xml = f.read()
-        f.close()
+        context = self._getImportContext(self._import_context_id)
+        xml = context.readDataFile(EXPORT_STEPS_XML)
 
         info_list = self._export_registry.parseXML( xml, encoding )
 
@@ -713,11 +666,8 @@
 
         """ Update our toolset registry from our profile.
         """
-        fq = self._getFullyQualifiedProfileDirectory()
-
-        f = open( os.path.join( fq, TOOLSET_XML ), 'r' )
-        xml = f.read()
-        f.close()
+        context = self._getImportContext(self._import_context_id)
+        xml = context.readDataFile(TOOLSET_XML)
 
         self._toolset_registry.parseXML( xml, encoding )
 



More information about the CMF-checkins mailing list