[CMF-checkins] CVS: CMF/CMFSetup - registry.py:1.12 tool.py:1.13

Tres Seaver tseaver at zope.com
Tue Jun 8 15:37:06 EDT 2004


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

Modified Files:
	registry.py tool.py 
Log Message:
 - Ensure that 'parse*XML' steps return data structures, rather than side effects.


=== CMF/CMFSetup/registry.py 1.11 => 1.12 ===
--- CMF/CMFSetup/registry.py:1.11	Sat May 29 21:50:05 2004
+++ CMF/CMFSetup/registry.py	Tue Jun  8 15:36:36 2004
@@ -205,23 +205,7 @@
         parser = _ImportStepRegistryParser( encoding )
         parseString( text, parser )
 
-        for step_info in parser._parsed:
-
-            id = step_info[ 'id' ]
-            version = step_info[ 'version' ]
-            handler = _resolveDottedName( step_info[ 'handler' ] )
-
-            dependencies = tuple( step_info.get( 'dependencies', () ) )
-            title = step_info.get( 'title', id )
-            description = ''.join( step_info.get( 'description', [] ) )
-
-            self.registerStep( id=id
-                             , version=version
-                             , handler=handler
-                             , dependencies=dependencies
-                             , title=title
-                             , description=description
-                             )
+        return parser._parsed
 
     #
     #   Helper methods
@@ -394,20 +378,7 @@
         parser = _ExportStepRegistryParser( encoding )
         parseString( text, parser )
 
-
-        for step_info in parser._parsed:
-
-            id = step_info[ 'id' ]
-            handler = _resolveDottedName( step_info[ 'handler' ] )
-
-            title = step_info.get( 'title', id )
-            description = ''.join( step_info.get( 'description', [] ) )
-
-            self.registerStep( id=id
-                             , handler=handler
-                             , title=title
-                             , description=description
-                             )
+        return parser._parsed
 
     #
     #   Helper methods
@@ -453,13 +424,15 @@
             self._pending = dict( [ ( k, self._extract( attrs, k ) )
                                     for k in attrs.keys() ] )
 
+            self._pending[ 'dependencies' ] = []
+
         elif name == 'dependency':
 
             if not self._pending:
                 raise ValueError, 'Dependency outside of step'
 
             depended = self._extract( attrs, 'step' )
-            self._pending.setdefault( 'dependencies', [] ).append( depended )
+            self._pending[ 'dependencies' ].append( depended )
 
         else:
             raise ValueError, 'Unknown element %s' % name
@@ -480,6 +453,12 @@
             if self._pending is None:
                 raise ValueError, 'No pending step!'
 
+            deps = tuple( self._pending[ 'dependencies' ] )
+            self._pending[ 'dependencies' ] = deps
+
+            desc = ''.join( self._pending[ 'description' ] )
+            self._pending[ 'description' ] = desc
+
             self._parsed.append( self._pending )
             self._pending = None
 
@@ -533,6 +512,9 @@
 
             if self._pending is None:
                 raise ValueError, 'No pending step!'
+
+            desc = ''.join( self._pending[ 'description' ] )
+            self._pending[ 'description' ] = desc
 
             self._parsed.append( self._pending )
             self._pending = None


=== CMF/CMFSetup/tool.py 1.12 => 1.13 ===
--- CMF/CMFSetup/tool.py:1.12	Sat May 29 22:13:07 2004
+++ CMF/CMFSetup/tool.py	Tue Jun  8 15:36:36 2004
@@ -21,6 +21,7 @@
 from registry import ImportStepRegistry
 from registry import ExportStepRegistry
 
+from utils import _resolveDottedName
 from utils import _wwwdir
 
 
@@ -430,7 +431,25 @@
         xml = f.read()
         f.close()
 
-        self._import_registry.parseXML( xml, encoding )
+        info_list = self._import_registry.parseXML( xml, encoding )
+
+        for step_info in info_list:
+
+            id = step_info[ 'id' ]
+            version = step_info[ 'version' ]
+            handler = _resolveDottedName( step_info[ 'handler' ] )
+
+            dependencies = tuple( step_info.get( 'dependencies', () ) )
+            title = step_info.get( 'title', id )
+            description = ''.join( step_info.get( 'description', [] ) )
+
+            self._import_registry.registerStep( id=id
+                                              , version=version
+                                              , handler=handler
+                                              , dependencies=dependencies
+                                              , title=title
+                                              , description=description
+                                              )
 
     security.declarePrivate( '_updateExportStepsRegistry' )
     def _updateExportStepsRegistry( self, encoding ):
@@ -443,7 +462,21 @@
         xml = f.read()
         f.close()
 
-        self._export_registry.parseXML( xml, encoding )
+        info_list = self._export_registry.parseXML( xml, encoding )
+
+        for step_info in info_list:
+
+            id = step_info[ 'id' ]
+            handler = _resolveDottedName( step_info[ 'handler' ] )
+
+            title = step_info.get( 'title', id )
+            description = ''.join( step_info.get( 'description', [] ) )
+
+            self._export_registry.registerStep( id=id
+                                              , handler=handler
+                                              , title=title
+                                              , description=description
+                                              )
 
     security.declarePrivate( '_doRunImportStep' )
     def _doRunImportStep( self, step_id, context ):




More information about the CMF-checkins mailing list