[Checkins] SVN: Zope3/branches/3.3/ - fixed bug that was hiding subsequent ImportErrors in the 'install' generation

Christian Theune cvs-admin at zope.org
Mon Jun 19 13:51:28 EDT 2006


Log message for revision 68759:
   - fixed bug that was hiding subsequent ImportErrors in the 'install' generation
  

Changed:
  U   Zope3/branches/3.3/doc/CHANGES.txt
  A   Zope3/branches/3.3/src/zope/app/generations/demo3/
  A   Zope3/branches/3.3/src/zope/app/generations/demo3/__init__.py
  A   Zope3/branches/3.3/src/zope/app/generations/demo3/install.py
  U   Zope3/branches/3.3/src/zope/app/generations/generations.py

-=-
Modified: Zope3/branches/3.3/doc/CHANGES.txt
===================================================================
--- Zope3/branches/3.3/doc/CHANGES.txt	2006-06-19 17:46:03 UTC (rev 68758)
+++ Zope3/branches/3.3/doc/CHANGES.txt	2006-06-19 17:51:24 UTC (rev 68759)
@@ -10,6 +10,9 @@
 
     Bugfixes
 
+      - The 'install' generation was hiding ImportErrors that happen within the
+        'install' module; they get re-raised now.
+
       - Fixed issue 550: Added adapter for datetime.datetime for xmlrpc
         premarshalling$
 

Added: Zope3/branches/3.3/src/zope/app/generations/demo3/__init__.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/generations/demo3/__init__.py	2006-06-19 17:46:03 UTC (rev 68758)
+++ Zope3/branches/3.3/src/zope/app/generations/demo3/__init__.py	2006-06-19 17:51:24 UTC (rev 68759)
@@ -0,0 +1,17 @@
+##############################################################################
+#
+# Copyright (c) 2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Demo package for evolution scripts (3)"""
+
+key = 'zope.app.generations.demo-generation'
+


Property changes on: Zope3/branches/3.3/src/zope/app/generations/demo3/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id Rev Date
Name: svn:eol-style
   + native

Added: Zope3/branches/3.3/src/zope/app/generations/demo3/install.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/generations/demo3/install.py	2006-06-19 17:46:03 UTC (rev 68758)
+++ Zope3/branches/3.3/src/zope/app/generations/demo3/install.py	2006-06-19 17:51:24 UTC (rev 68759)
@@ -0,0 +1,27 @@
+##############################################################################
+#
+# Copyright (c) 2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Silly demo evolution module
+
+$Id$
+"""
+__docformat__ = 'restructuredtext'
+
+generation = 3
+
+import zope.app.generations.demo
+
+import zope.nonexistingmodule
+
+def evolve(context):
+    pass


Property changes on: Zope3/branches/3.3/src/zope/app/generations/demo3/install.py
___________________________________________________________________
Name: svn:keywords
   + Id Rev Date
Name: svn:eol-style
   + native

Modified: Zope3/branches/3.3/src/zope/app/generations/generations.py
===================================================================
--- Zope3/branches/3.3/src/zope/app/generations/generations.py	2006-06-19 17:46:03 UTC (rev 68758)
+++ Zope3/branches/3.3/src/zope/app/generations/generations.py	2006-06-19 17:51:24 UTC (rev 68759)
@@ -17,6 +17,8 @@
 """
 __docformat__ = 'restructuredtext'
 
+import sys
+
 from interfaces import GenerationTooHigh, GenerationTooLow, UnableToEvolve
 from interfaces import ISchemaManager, IInstallableSchemaManager
 import logging
@@ -95,6 +97,13 @@
          >>> manager = SchemaManager(1, 3, 'zope.app.generations.demo2')
          >>> manager.install(context)
 
+       We handle ImportErrors within the script specially, so they get promoted:
+
+         >>> manager = SchemaManager(1, 3, 'zope.app.generations.demo3')
+         >>> manager.install(context)
+         Traceback (most recent call last):
+         ImportError: No module named nonexistingmodule
+
        We'd better clean up:
 
          >>> context.connection.close()
@@ -125,7 +134,6 @@
     def evolve(self, context, generation):
         """Evolve a database to reflect software/schema changes
         """
-
         name = "%s.evolve%d" % (self.package_name, generation)
 
         evolver = __import__(name, {}, {}, ['*'])
@@ -135,14 +143,15 @@
     def install(self, context):
         """Evolve a database to reflect software/schema changes
         """
-
         name = "%s.install" % self.package_name
 
         try:
-            evolver = __import__("%s.install" % self.package_name,
-                                 {}, {}, ['*'])
-        except ImportError:
-            pass
+            evolver = __import__(name, {}, {}, ['*'])
+        except ImportError, m:
+            if str(m) not in ('No module named %s' % name,
+                              'No module named install'):
+                # This was an import error *within* the module, so we re-raise.
+                raise
         else:
             evolver.evolve(context)
 



More information about the Checkins mailing list