[CMF-checkins] CVS: CMF/CMFSetup - actions.py:1.19 properties.py:1.3 typeinfo.py:1.21

Yvo Schubbe y.2005- at wcm-solutions.de
Sun Mar 13 11:23:58 EST 2005


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

Modified Files:
	actions.py properties.py typeinfo.py 
Log Message:
don't complain if there is nothing to import


=== CMF/CMFSetup/actions.py 1.18 => 1.19 ===
--- CMF/CMFSetup/actions.py:1.18	Tue Jan 25 14:49:42 2005
+++ CMF/CMFSetup/actions.py	Sun Mar 13 11:23:57 2005
@@ -75,62 +75,60 @@
         for obj_id in actions_tool.objectIds():
             actions_tool._delObject(obj_id)
 
-    text = context.readDataFile( _FILENAME )
+    xml = context.readDataFile(_FILENAME)
+    if xml is None:
+        return 'Action providers: Nothing to import.'
+
+    apc = ActionProvidersConfigurator(site, encoding)
+    tool_info = apc.parseXML(xml)
+
+    for p_info in tool_info['providers']:
+
+        if p_info['id'] in _SPECIAL_PROVIDERS and \
+                p_info['id'] not in actions_tool.listActionProviders():
+            actions_tool.addActionProvider(p_info['id'])
+
+        provider = getToolByName(site, p_info['id'])
+        provider._actions = ()
+
+        for a_info in p_info['actions']:
+            parent = actions_tool
+            for category_id in a_info['category'].split('/'):
+                if category_id not in parent.objectIds():
+                    o_info = {'id': str(category_id),
+                              'meta_type': 'CMF Action Category',
+                              'properties':(),
+                              'objects': ()}
+                    apc.initObject(parent, o_info)
+                parent = parent._getOb(category_id)
+            if a_info['id'] not in parent.objectIds():
+                o_info = {'id': str(a_info['id']),
+                          'meta_type': 'CMF Action',
+                          'properties':
+                             ( {'id': 'title',
+                                'value': a_info.get('title', ''),
+                                'elements': ()}
+                             , {'id': 'description',
+                                'value': a_info.get('description', ''),
+                                'elements': ()}
+                             , {'id': 'url_expr',
+                                'value': a_info.get('action', ''),
+                                'elements': ()}
+                             , {'id': 'available_expr',
+                                'value': a_info.get('condition', ''),
+                                'elements': ()}
+                             , {'id': 'permissions',
+                                'value': '',
+                                'elements': a_info['permissions']}
+                             , {'id': 'visible',
+                                'value': a_info.get('visible', True),
+                                'elements': ()}
+                             ),
+                          'objects': ()}
+                apc.initObject(parent, o_info)
 
-    if text is not None:
-
-        apc = ActionProvidersConfigurator( site, encoding )
-        tool_info = apc.parseXML( text )
-
-        for p_info in tool_info[ 'providers' ]:
-
-            if p_info[ 'id' ] in _SPECIAL_PROVIDERS and \
-                    p_info[ 'id' ] not in actions_tool.listActionProviders():
-
-                actions_tool.addActionProvider( p_info[ 'id' ] )
-
-            provider = getToolByName( site, p_info[ 'id' ] )
-            provider._actions = ()
-
-            if p_info['actions']:
-                for a_info in p_info['actions']:
-                    parent = actions_tool
-                    for category_id in a_info['category'].split('/'):
-                        if category_id not in parent.objectIds():
-                            o_info = {'id': str(category_id),
-                                      'meta_type': 'CMF Action Category',
-                                      'properties':(),
-                                      'objects': ()}
-                            apc.initObject(parent, o_info)
-                        parent = parent._getOb(category_id)
-                    if a_info['id'] not in parent.objectIds():
-                        o_info = {'id': str(a_info['id']),
-                                  'meta_type': 'CMF Action',
-                                  'properties':
-                                     ( {'id': 'title',
-                                        'value': a_info.get('title', ''),
-                                        'elements': ()}
-                                     , {'id': 'description',
-                                        'value': a_info.get('description', ''),
-                                        'elements': ()}
-                                     , {'id': 'url_expr',
-                                        'value': a_info.get('action', ''),
-                                        'elements': ()}
-                                     , {'id': 'available_expr',
-                                        'value': a_info.get('condition', ''),
-                                        'elements': ()}
-                                     , {'id': 'permissions',
-                                        'value': '',
-                                        'elements': a_info['permissions']}
-                                     , {'id': 'visible',
-                                        'value': a_info.get('visible', True),
-                                        'elements': ()}
-                                     ),
-                                  'objects': ()}
-                        apc.initObject(parent, o_info)
-
-    for sub_info in tool_info[ 'objects' ]:
-        apc.initObject( actions_tool, sub_info )
+    for sub_info in tool_info['objects']:
+        apc.initObject(actions_tool, sub_info)
 
     return 'Action providers imported.'
 


=== CMF/CMFSetup/properties.py 1.2 => 1.3 ===
--- CMF/CMFSetup/properties.py:1.2	Fri Dec 17 12:51:10 2004
+++ CMF/CMFSetup/properties.py	Sun Mar 13 11:23:57 2005
@@ -51,6 +51,9 @@
                 site._updateProperty(prop_id, prop_value)
 
     xml = context.readDataFile(_FILENAME)
+    if xml is None:
+        return 'Site properties: Nothing to import.'
+
     spc = SitePropertiesConfigurator(site, encoding)
     site_info = spc.parseXML(xml)
 


=== CMF/CMFSetup/typeinfo.py 1.20 => 1.21 ===
--- CMF/CMFSetup/typeinfo.py:1.20	Thu Mar 10 09:46:29 2005
+++ CMF/CMFSetup/typeinfo.py	Sun Mar 13 11:23:57 2005
@@ -52,9 +52,11 @@
             types_tool._delObject(type)
 
     ttc = TypesToolConfigurator( site, encoding )
-    text = context.readDataFile( _TOOL_FILENAME )
-    tool_info = ttc.parseXML( text )
+    xml = context.readDataFile( _TOOL_FILENAME )
+    if xml is None:
+        return 'Types tool: Nothing to import.'
 
+    tool_info = ttc.parseXML( xml )
     tic = TypeInfoConfigurator( site, encoding )
 
     for type_info in tool_info[ 'types' ]:
@@ -84,7 +86,7 @@
     # importScriptsToContainer(types_tool, ('typestool_scripts',),
     #                          context)
 
-    return 'Type tool imported'
+    return 'Types tool imported.'
 
 def exportTypesTool( context ):
 



More information about the CMF-checkins mailing list