[migration] dont crash if a group doesn't exists (it may not exists yet) stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 06 Aug 2010 17:37:34 +0200
branchstable
changeset 6075 6ebecb217efe
parent 6074 f2580c7abc26
child 6076 aa7402e998a1
[migration] dont crash if a group doesn't exists (it may not exists yet)
server/migractions.py
--- a/server/migractions.py	Fri Aug 06 17:37:06 2010 +0200
+++ b/server/migractions.py	Fri Aug 06 17:37:34 2010 +0200
@@ -378,9 +378,13 @@
             for gname in newgroups:
                 if not confirm or self.confirm('Grant %s permission of %s to %s?'
                                                % (action, erschema, gname)):
-                    self.rqlexec('SET T %s G WHERE G eid %%(x)s, T eid %s'
-                                 % (perm, teid),
-                                 {'x': gm[gname]}, ask_confirm=False)
+                    try:
+                        self.rqlexec('SET T %s G WHERE G eid %%(x)s, T eid %s'
+                                     % (perm, teid),
+                                     {'x': gm[gname]}, ask_confirm=False)
+                    except KeyError:
+                        self.error('can grant %s perm to unexistant group %s',
+                                   action, gname)
             # handle rql expressions
             newexprs = dict((expr.expression, expr) for expr in erschema.get_rqlexprs(action))
             for expreid, expression in self.rqlexec('Any E, EX WHERE T %s E, E expression EX, '