let exception propagate
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 24 Jun 2009 15:27:36 +0200
changeset 38 8bdf21b39de0
parent 37 eecf61767e2a
child 39 e9dbdb3aa6cb
let exception propagate
views.py
--- a/views.py	Wed Jun 24 15:27:24 2009 +0200
+++ b/views.py	Wed Jun 24 15:27:36 2009 +0200
@@ -130,28 +130,24 @@
 @basecontrollers.jsonize
 def js_add_keywords(self, eid, kwlist):
     msg = self.req._('keywords applied')
-    try:
-        kwrset = self.cursor.execute('Any K,N,C WHERE K is Keyword, K name N, K included_in C, '
-                                     'C classifies ET, X eid %(x)s, X is ET',
-                                     {'x' : eid}, 'x')
-        if not kwrset:
-            return self.req._('No suitable classification scheme found')
-        classification = kwrset[0][2] # XXX what if we have several classifications ?
-        valid_keywords = set(kwname for _, kwname,_ in kwrset)
-        user_keywords = set(kwlist)
-        invalid_keywords = sorted(user_keywords - valid_keywords)
-        kweids = dict( (kwname, str(kweid)) for kweid, kwname, _ in kwrset if kwname in user_keywords )
-        if invalid_keywords:
-            for keyword in invalid_keywords:
-                neweid = self.cursor.execute('INSERT Keyword K: K name %(name)s, K included_in C WHERE C eid %(c)s',
-                                             {'name' : keyword, 'c' : classification}, 'c')[0][0]
-                kweids[keyword] = str(neweid)
-            if not self.req.user.is_in_group('managers'):
-                msg += self.req._(' but keywords %s must be validated') % u', '.join(invalid_keywords)
-        if kweids:
-            self.cursor.execute('SET KW applied_to X WHERE X eid %%(x)s, KW eid IN (%s)'
-                                % ','.join(kweids.values()), {'x' : eid}, 'x')
-    except Exception, ex:
-        self.exception(unicode(ex))
-        return self.req._('A problem occured while applying keywords')
+    kwrset = self.cursor.execute('Any K,N,C WHERE K is Keyword, K name N, K included_in C, '
+                                 'C classifies ET, X eid %(x)s, X is ET',
+                                 {'x' : eid}, 'x')
+    if not kwrset:
+        return self.req._('No suitable classification scheme found')
+    classification = kwrset[0][2] # XXX what if we have several classifications ?
+    valid_keywords = set(kwname for _, kwname,_ in kwrset)
+    user_keywords = set(kwlist)
+    invalid_keywords = sorted(user_keywords - valid_keywords)
+    kweids = dict( (kwname, str(kweid)) for kweid, kwname, _ in kwrset if kwname in user_keywords )
+    if invalid_keywords:
+        for keyword in invalid_keywords:
+            neweid = self.cursor.execute('INSERT Keyword K: K name %(name)s, K included_in C WHERE C eid %(c)s',
+                                         {'name' : keyword, 'c' : classification}, 'c')[0][0]
+            kweids[keyword] = str(neweid)
+        if not self.req.user.is_in_group('managers'):
+            msg += self.req._(' but keywords %s must be validated') % u', '.join(invalid_keywords)
+    if kweids:
+        self.cursor.execute('SET KW applied_to X WHERE X eid %%(x)s, KW eid IN (%s)'
+                            % ','.join(kweids.values()), {'x' : eid}, 'x')
     return msg