[migration] fix bug in `CWAttributeAddOp.revertprecommit_event`

The rdefdef attribute is set during the operation execution. In some the operation crash before this assignment. In such case revertprecommit raise an attribute error crashing the whole process and shadowing the original error.

This changeset detect and Avoid this situation.

authorPierre-Yves David <pierre-yves.david@logilab.fr>
changesetd8b0984c923c
brancholdstable
phasepublic
hiddenno
parent revision#88c71ad83d47 3.15 is the new old stable
child revision#dbffb6959564 server/source/native: fix wrong usage of .lstrip that produce garbled error messages (closes #2777641), #aef3109aea64 server/source/native: fix wrong usage of .lstrip that produce garbled error messages (closes #2777641)
files modified by this revision
hooks/syncschema.py
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1364467517 -3600
# Thu Mar 28 11:45:17 2013 +0100
# Branch oldstable
# Node ID d8b0984c923c45e9be2ef499d4d1f7d31dfd2a85
# Parent 88c71ad83d47b38367d2ccd3cee1a980b40009ff
[migration] fix bug in `CWAttributeAddOp.revertprecommit_event`

The `rdefdef` attribute is set during the operation execution. In some the
operation crash before this assignment. In such case `revertprecommit` raise an
attribute error crashing the whole process and shadowing the original error.

This changeset detect and Avoid this situation.

diff --git a/hooks/syncschema.py b/hooks/syncschema.py
@@ -505,10 +505,12 @@
1                  session.system_sql('UPDATE %s SET %s=%%(default)s' % (table, column),
2                                     {'default': default})
3 
4      def revertprecommit_event(self):
5          # revert changes on in memory schema
6 +        if getattr(self, 'rdefdef', None) is None:
7 +            return
8          self.session.vreg.schema.del_relation_def(
9              self.rdefdef.subject, self.rdefdef.name, self.rdefdef.object)
10          # XXX revert changes on database
11 
12