[Checkins] SVN: GenericSetup/trunk/ Fixed toolset import handler not to initialize tools again, when they already exist in the site.

Hanno Schlichting plone at hannosch.info
Wed Oct 31 03:56:54 EDT 2007


Log message for revision 81265:
  Fixed toolset import handler not to initialize tools again, when they already exist in the site.
  

Changed:
  U   GenericSetup/trunk/CHANGES.txt
  U   GenericSetup/trunk/tool.py

-=-
Modified: GenericSetup/trunk/CHANGES.txt
===================================================================
--- GenericSetup/trunk/CHANGES.txt	2007-10-31 05:14:08 UTC (rev 81264)
+++ GenericSetup/trunk/CHANGES.txt	2007-10-31 07:56:54 UTC (rev 81265)
@@ -1,6 +1,10 @@
 GenericSetup Product Changelog
 
+  GenericSetup 1.3.3 (unreleased)
 
+    - tool: Fixed toolset import handler not to initialize tools again, when
+      they already exist in the site.
+
   GenericSetup 1.3.2 (unreleased)
 
     - Ignore import and export step handlers that we can not resolve.

Modified: GenericSetup/trunk/tool.py
===================================================================
--- GenericSetup/trunk/tool.py	2007-10-31 05:14:08 UTC (rev 81264)
+++ GenericSetup/trunk/tool.py	2007-10-31 07:56:54 UTC (rev 81265)
@@ -27,6 +27,7 @@
 from OFS.Folder import Folder
 from OFS.Image import File
 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
+from ZODB.POSException import ConflictError
 from zope.interface import implements
 from zope.interface import implementedBy
 
@@ -105,23 +106,25 @@
         tool_class = _resolveDottedName(info['class'])
 
         existing = getattr(aq_base(site), tool_id, None)
-        try:
-            new_tool = tool_class()
-        except TypeError:
-            new_tool = tool_class(tool_id)
-        else:
+        # Don't even initialize the tool again, if it already exists.
+        if existing is None:
             try:
-                new_tool._setId(tool_id)
-            except: # XXX:  ImmutableId raises result of calling MessageDialog
-                pass
+                new_tool = tool_class()
+            except TypeError:
+                new_tool = tool_class(tool_id)
+            else:
+                try:
+                    new_tool._setId(tool_id)
+                except (ConflictError, KeyboardInterrupt):
+                    raise
+                except:
+                    # XXX: ImmutableId raises result of calling MessageDialog
+                    pass
 
-        if existing is None:
             site._setObject(tool_id, new_tool)
-
         else:
             unwrapped = aq_base(existing)
             if not isinstance(unwrapped, tool_class):
-
                 site._delObject(tool_id)
                 site._setObject(tool_id, tool_class())
 



More information about the Checkins mailing list