web/views/basecontrollers.py
branchtls-sprint
changeset 1798 cc86fe8efaaa
parent 1795 abffc24f93c5
child 1827 93840d187f26
child 1838 d4cbcc15c01c
--- a/web/views/basecontrollers.py	Wed May 13 17:21:35 2009 +0200
+++ b/web/views/basecontrollers.py	Wed May 13 19:51:30 2009 +0200
@@ -382,8 +382,8 @@
             else:
                 eid = err.entity.eid
             return (False, (eid, err.errors))
-        except Redirect, err:
-            return (True, err.location)
+        except Redirect, redir:
+            return (True, redir.location)
         except Exception, err:
             self.req.cnx.rollback()
             self.exception('unexpected error in js_validateform')
@@ -391,7 +391,7 @@
         return (False, '???')
 
     @jsonize
-    def js_edit_field(self, action, names, values, rtype, eid):
+    def js_edit_field(self, action, names, values, rtype, eid, default):
         success, args = self.validate_form(action, names, values)
         if success:
             # Any X,N where we don't seem to use N is an optimisation
@@ -400,18 +400,22 @@
                                     {'x': eid}, 'x')
             entity = rset.get_entity(0, 0)
             value = entity.printable_value(rtype)
-            return (success, args, value or self.req._('not specified'))
+            return (success, args, value or default)
         else:
             return (success, args, None)
 
     @jsonize
     def js_edit_relation(self, action, names, values,
-                         rtype, eid, vid, role='subject'):
+                         rtype, role, eid, vid, default):
         success, args = self.validate_form(action, names, values)
         if success:
             entity = self.req.eid_rset(eid).get_entity(0, 0)
             rset = entity.related(rtype, role)
-            return (success, args, self.view(vid, rset))
+            if rset:
+                output = self.view(vid, rset)
+            else:
+                output = default
+            return (success, args, output)
         else:
             return (success, args, None)