[Zope3-checkins]
SVN: Zope3/trunk/src/zope/app/generations/generations.py
Added a try/except around execution of installation scripts to abort
Jim Fulton
jim at zope.com
Mon Feb 21 11:28:56 EST 2005
Log message for revision 29234:
Added a try/except around execution of installation scripts to abort
on error and reraise.
Changed:
U Zope3/trunk/src/zope/app/generations/generations.py
-=-
Modified: Zope3/trunk/src/zope/app/generations/generations.py
===================================================================
--- Zope3/trunk/src/zope/app/generations/generations.py 2005-02-21 16:17:38 UTC (rev 29233)
+++ Zope3/trunk/src/zope/app/generations/generations.py 2005-02-21 16:28:55 UTC (rev 29234)
@@ -55,7 +55,7 @@
>>> manager.evolve(context, 2)
>>> manager.evolve(context, 3)
- >>> get_transaction().commit()
+ >>> transaction.commit()
The demo evolvers simply record their data in a root key:
@@ -80,11 +80,11 @@
>>> conn.sync()
>>> del conn.root()[key]
- >>> get_transaction().commit()
+ >>> transaction.commit()
>>> conn.root().get(key)
>>> manager.install(context)
- >>> get_transaction().commit()
+ >>> transaction.commit()
>>> conn.sync()
>>> conn.root()[key]
('installed',)
@@ -356,7 +356,7 @@
generations = root.get(generations_key)
if generations is None:
generations = root[generations_key] = PersistentDict()
- get_transaction().commit()
+ transaction.commit()
for key, manager in findManagers():
generation = generations.get(key)
@@ -366,11 +366,19 @@
if generation is None:
# This is a new database, so no old data
+
if IInstallableSchemaManager.providedBy(manager):
- manager.install(context)
-
+ try:
+ manager.install(context)
+ except:
+ transaction.abort()
+ logging.getLogger('zope.app.generations').exception(
+ "Failed to install %s",
+ key)
+ raise
+
generations[key] = manager.generation
- get_transaction().commit()
+ transaction.commit()
continue
if generation > manager.generation:
@@ -395,10 +403,10 @@
transaction.begin()
manager.evolve(context, generation)
generations[key] = generation
- get_transaction().commit()
+ transaction.commit()
except:
# An unguarded handler is intended here
- get_transaction().abort()
+ transaction.abort()
logging.getLogger('zope.app.generations').exception(
"Failed to evolve database to generation %d for %s",
generation, key)
More information about the Zope3-Checkins
mailing list