[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/generations/ -
ported a fix from 3.3 branch: fixed hiding of ImportErrors
during 'install'
Christian Theune
cvs-admin at zope.org
Mon Jun 19 14:02:57 EDT 2006
Log message for revision 68762:
- ported a fix from 3.3 branch: fixed hiding of ImportErrors during 'install'
generation
Changed:
A Zope3/trunk/src/zope/app/generations/demo3/
A Zope3/trunk/src/zope/app/generations/demo3/__init__.py
A Zope3/trunk/src/zope/app/generations/demo3/install.py
U Zope3/trunk/src/zope/app/generations/generations.py
-=-
Added: Zope3/trunk/src/zope/app/generations/demo3/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/generations/demo3/__init__.py 2006-06-19 18:02:25 UTC (rev 68761)
+++ Zope3/trunk/src/zope/app/generations/demo3/__init__.py 2006-06-19 18:02:54 UTC (rev 68762)
@@ -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/trunk/src/zope/app/generations/demo3/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id Rev Date
Name: svn:eol-style
+ native
Added: Zope3/trunk/src/zope/app/generations/demo3/install.py
===================================================================
--- Zope3/trunk/src/zope/app/generations/demo3/install.py 2006-06-19 18:02:25 UTC (rev 68761)
+++ Zope3/trunk/src/zope/app/generations/demo3/install.py 2006-06-19 18:02:54 UTC (rev 68762)
@@ -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/trunk/src/zope/app/generations/demo3/install.py
___________________________________________________________________
Name: svn:keywords
+ Id Rev Date
Name: svn:eol-style
+ native
Modified: Zope3/trunk/src/zope/app/generations/generations.py
===================================================================
--- Zope3/trunk/src/zope/app/generations/generations.py 2006-06-19 18:02:25 UTC (rev 68761)
+++ Zope3/trunk/src/zope/app/generations/generations.py 2006-06-19 18:02:54 UTC (rev 68762)
@@ -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 Zope3-Checkins
mailing list