diff roundup/cgi/client.py @ 1520:9728e5c55633

re-enabled "expected" exception handlers
author Richard Jones <richard@users.sourceforge.net>
date Mon, 17 Mar 2003 04:26:24 +0000
parents 4013ef6690e9
children 709bb731e96e
line wrap: on
line diff
--- a/roundup/cgi/client.py	Sun Mar 16 22:24:56 2003 +0000
+++ b/roundup/cgi/client.py	Mon Mar 17 04:26:24 2003 +0000
@@ -1,4 +1,4 @@
-# $Id: client.py,v 1.104 2003-03-09 22:57:47 richard Exp $
+# $Id: client.py,v 1.105 2003-03-17 04:26:24 richard Exp $
 
 __doc__ = """
 WWW request handler (also used in the stand-alone server).
@@ -815,17 +815,16 @@
         # create the new user
         cl = self.db.user
 # XXX we need to make the "default" page be able to display errors!
-#        try:
-        if 1:
+        try:
             props['roles'] = self.instance.config.NEW_WEB_USER_ROLES
             del props['__time']
             self.userid = cl.create(**props)
             # clear the props from the otk database
             self.db.otks.destroy(otk)
             self.db.commit()
-#        except (ValueError, KeyError), message:
-#            self.error_message.append(str(message))
-#            return
+        except (ValueError, KeyError), message:
+            self.error_message.append(str(message))
+            return
 
         # log the new user in
         self.user = cl.get(self.userid, 'username')
@@ -866,17 +865,16 @@
             newpw = ''.join([random.choice(self.chars) for x in range(8)])
 
             cl = self.db.user
-    # XXX we need to make the "default" page be able to display errors!
-    #        try:
-            if 1:
+# XXX we need to make the "default" page be able to display errors!
+            try:
                 # set the password
                 cl.set(uid, password=password.Password(newpw))
                 # clear the props from the otk database
                 self.db.otks.destroy(otk)
                 self.db.commit()
-    #        except (ValueError, KeyError), message:
-    #            self.error_message.append(str(message))
-    #            return
+            except (ValueError, KeyError), message:
+                self.error_message.append(str(message))
+                return
 
             # user info
             address = self.db.user.get(uid, 'address')
@@ -944,22 +942,18 @@
            See parsePropsFromForm and _editnodes for special variables
         '''
         # parse the props from the form
-# XXX reinstate exception handling
-#        try:
-        if 1:
+        try:
             props, links = self.parsePropsFromForm()
-#        except (ValueError, KeyError), message:
-#            self.error_message.append(_('Error: ') + str(message))
-#            return
+        except (ValueError, KeyError), message:
+            self.error_message.append(_('Error: ') + str(message))
+            return
 
         # handle the props
-# XXX reinstate exception handling
-#        try:
-        if 1:
+        try:
             message = self._editnodes(props, links)
-#        except (ValueError, KeyError, IndexError), message:
-#            self.error_message.append(_('Error: ') + str(message))
-#            return
+        except (ValueError, KeyError, IndexError), message:
+            self.error_message.append(_('Error: ') + str(message))
+            return
 
         # commit now that all the tricky stuff is done
         self.db.commit()
@@ -999,34 +993,27 @@
             special form values.
         '''
         # parse the props from the form
-# XXX reinstate exception handling
-#        try:
-        if 1:
+        try:
             props, links = self.parsePropsFromForm()
-#        except (ValueError, KeyError), message:
-#            self.error_message.append(_('Error: ') + str(message))
-#            return
+        except (ValueError, KeyError), message:
+            self.error_message.append(_('Error: ') + str(message))
+            return
 
         # handle the props - edit or create
-# XXX reinstate exception handling
-#        try:
-        if 1:
-            # create the context here
-#            cn = self.classname
-#            nid = self._createnode(cn, props[(cn, None)])
-#            del props[(cn, None)]
+        try:
+            # when it hits the None element, it'll set self.nodeid
+            messages = self._editnodes(props, links)
 
-            # when it hits the None element, it'll set self.nodeid
-            messages = self._editnodes(props, links) #, {(cn, None): nid})
-
-#        except (ValueError, KeyError, IndexError), message:
-#            # these errors might just be indicative of user dumbness
-#            self.error_message.append(_('Error: ') + str(message))
-#            return
+        except (ValueError, KeyError, IndexError), message:
+            # these errors might just be indicative of user dumbness
+            self.error_message.append(_('Error: ') + str(message))
+            return
 
         # commit now that all the tricky stuff is done
         self.db.commit()
 
+        print '%s%s%s?@ok_message=%s'%(self.base, self.classname,
+            self.nodeid, urllib.quote(messages))
         # redirect to the new item's page
         raise Redirect, '%s%s%s?@ok_message=%s'%(self.base, self.classname,
             self.nodeid, urllib.quote(messages))

Roundup Issue Tracker: http://roundup-tracker.org/