[CMF-checkins] CVS: CMF/CMFSetup - PROFILES.txt:1.2 actions.py:1.20 skins.py:1.14 tool.py:1.23 utils.py:1.18

Yvo Schubbe y.2005- at wcm-solutions.de
Mon Apr 11 07:33:47 EDT 2005


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

Modified Files:
	actions.py skins.py tool.py utils.py 
Added Files:
	PROFILES.txt 
Log Message:
improved update behavior of extension profiles (see PROFILES.txt for details)


=== CMF/CMFSetup/PROFILES.txt 1.1 => 1.2 ===
--- /dev/null	Mon Apr 11 07:33:47 2005
+++ CMF/CMFSetup/PROFILES.txt	Mon Apr 11 07:33:17 2005
@@ -0,0 +1,34 @@
+Profiles
+
+  Overview
+
+    There are two different kinds of profiles: Base profiles and extension
+    profiles. Base profiles have no dependencies. Extension profiles are
+    profile fragments used to modify base profiles. They can be shipped with
+    add-on products or used for customization steps. Importing an extension
+    profile adds or overwrites existing settings in a fine-grained way. You
+    can't export extension profiles. Snapshots and exports always represent
+    the merged settings.
+
+  Update Directives
+
+    For some XML elements there are additional attributes and values to
+    specify update directives. They are only useful for extension profiles and
+    you will never see them in snapshots and exports.
+
+    'insert-before' and 'insert-after'
+
+      applies to: object (generic); layer (skins.xml)
+
+      'insert-before' and 'insert-after' specify the position of a new item
+      relative to an existing item. If they are omitted or not valid, items
+      are appended. You can also use '*' as wildcard. This will insert the new
+      item at the top (before all existing items) or the bottom (after all
+      existing items). If an item with the given ID exists already, it is
+      moved to the specified position.
+
+    'id="*"' wildcard
+
+      applies to: skin-path (skins.xml)
+
+      Updates all existing items in the container with the same settings.


=== CMF/CMFSetup/actions.py 1.19 => 1.20 ===
--- CMF/CMFSetup/actions.py:1.19	Sun Mar 13 11:23:57 2005
+++ CMF/CMFSetup/actions.py	Mon Apr 11 07:33:17 2005
@@ -217,7 +217,7 @@
 
         return {
           'actions-tool':
-             { 'action-provider': {KEY: 'providers'},
+             { 'action-provider': {KEY: 'providers', DEFAULT: ()},
                'object':          {KEY: 'objects', DEFAULT: ()} },
           'action-provider':
              { 'id':              {},


=== CMF/CMFSetup/skins.py 1.13 => 1.14 ===
--- CMF/CMFSetup/skins.py:1.13	Sun Mar 27 12:41:42 2005
+++ CMF/CMFSetup/skins.py	Mon Apr 11 07:33:17 2005
@@ -135,20 +135,29 @@
     for layer in layer_infos:
         if layer['name'] in path:
             path.remove(layer['name'])
+
         if 'insert-before' in layer:
-            try:
-                index = path.index(layer['insert-before'])
-                path.insert(index, layer['name'])
+            if layer['insert-before'] == '*':
+                path.insert(0, layer['name'])
                 continue
-            except ValueError:
-                pass
-        if 'insert-after' in layer:
-            try:
-                index = path.index(layer['insert-after'])
-                path.insert(index+1, layer['name'])
-                continue
-            except ValueError:
+            else:
+                try:
+                    index = path.index(layer['insert-before'])
+                    path.insert(index, layer['name'])
+                    continue
+                except ValueError:
+                    pass
+        elif 'insert-after' in layer:
+            if layer['insert-after'] == '*':
                 pass
+            else:
+                try:
+                    index = path.index(layer['insert-after'])
+                    path.insert(index+1, layer['name'])
+                    continue
+                except ValueError:
+                    pass
+
         path.append(layer['name'])
 
     return str( ','.join(path) )


=== CMF/CMFSetup/tool.py 1.22 => 1.23 ===
--- CMF/CMFSetup/tool.py:1.22	Wed Mar 16 03:22:34 2005
+++ CMF/CMFSetup/tool.py	Mon Apr 11 07:33:17 2005
@@ -69,12 +69,15 @@
     """
     site = context.getSite()
     encoding = context.getEncoding()
-    text = context.readDataFile( TOOLSET_XML )
+
+    xml = context.readDataFile(TOOLSET_XML)
+    if xml is None:
+        return 'Toolset: Nothing to import.'
 
     setup_tool = getToolByName( site, 'portal_setup' )
     toolset = setup_tool.getToolsetRegistry()
 
-    toolset.parseXML(text, encoding)
+    toolset.parseXML(xml, encoding)
 
     existing_ids = site.objectIds()
     existing_values = site.objectValues()
@@ -100,7 +103,7 @@
                 site._delObject( tool_id )
                 site._setObject( tool_id, tool_class() )
 
-    return 'Toolset imported'
+    return 'Toolset imported.'
 
 def exportToolset( context ):
 
@@ -113,7 +116,7 @@
     xml = toolset.generateXML()
     context.writeDataFile( TOOLSET_XML, xml, 'text/xml' )
 
-    return 'Toolset exported'
+    return 'Toolset exported.'
 
 
 class SetupTool( UniqueObject, Folder ):


=== CMF/CMFSetup/utils.py 1.17 => 1.18 ===
--- CMF/CMFSetup/utils.py:1.17	Tue Apr  5 13:20:12 2005
+++ CMF/CMFSetup/utils.py	Mon Apr 11 07:33:17 2005
@@ -218,6 +218,8 @@
           'object':
             { 'name':            {KEY: 'id'},
               'meta_type':       {},
+              'insert-before':   {},
+              'insert-after' :   {},
               'property':        {KEY: 'properties', DEFAULT: ()},
               'object':          {KEY: 'objects', DEFAULT: ()} },
           'property':
@@ -263,7 +265,7 @@
     security.declareProtected(ManagePortal, 'initObject')
     def initObject(self, parent, o_info):
 
-        obj_id = o_info['id']
+        obj_id = str(o_info['id'])
         if obj_id not in parent.objectIds():
             meta_type = o_info['meta_type']
             for mt_info in Products.meta_types:
@@ -273,6 +275,25 @@
             else:
                 raise ValueError('unknown meta_type \'%s\'' % obj_id)
         obj = parent._getOb(obj_id)
+
+        if 'insert-before' in o_info:
+            if o_info['insert-before'] == '*':
+                parent.moveObjectsToTop(obj_id)
+            else:
+                try:
+                    position = parent.getObjectPosition(o_info['insert-before'])
+                    parent.moveObjectToPosition(obj_id, position)
+                except ValueError:
+                    pass
+        elif 'insert-after' in o_info:
+            if o_info['insert-after'] == '*':
+                parent.moveObjectsToBottom(obj_id)
+            else:
+                try:
+                    position = parent.getObjectPosition(o_info['insert-after'])
+                    parent.moveObjectToPosition(obj_id, position+1)
+                except ValueError:
+                    pass
 
         [ self.initObject(obj, info) for info in o_info['objects'] ]
 



More information about the CMF-checkins mailing list