[services] catch missing group early in register_user
authorJulien Cristau <julien.cristau@logilab.fr>
Wed, 23 Apr 2014 18:17:42 +0200
changeset 9691 b9ca1551f14b
parent 9690 2b506822ca54
child 9692 8574479184c4
[services] catch missing group early in register_user Better an assertion than a rql syntax error for such a programming error.
sobjects/services.py
--- a/sobjects/services.py	Wed Apr 23 18:16:46 2014 +0200
+++ b/sobjects/services.py	Wed Apr 23 18:17:42 2014 +0200
@@ -140,6 +140,7 @@
         user = cnx.create_entity('CWUser', **cwuserkwargs)
         if groups is None:
             groups = self.default_groups
+        assert groups, "CWUsers must belong to at least one CWGroup"
         group_names = ', '.join('%r' % group for group in groups)
         cnx.execute('SET X in_group G WHERE X eid %%(x)s, G name IN (%s)' % group_names,
                     {'x': user.eid})