Skip to content

Commit 5420e64

Browse files
author
Richard Jones
committed
re-enabled "expected" exception handlers
1 parent 51fafc1 commit 5420e64

File tree

1 file changed

+30
-43
lines changed

1 file changed

+30
-43
lines changed

roundup/cgi/client.py

Lines changed: 30 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: client.py,v 1.104 2003-03-09 22:57:47 richard Exp $
1+
# $Id: client.py,v 1.105 2003-03-17 04:26:24 richard Exp $
22

33
__doc__ = """
44
WWW request handler (also used in the stand-alone server).
@@ -815,17 +815,16 @@ def confRegoAction(self):
815815
# create the new user
816816
cl = self.db.user
817817
# XXX we need to make the "default" page be able to display errors!
818-
# try:
819-
if 1:
818+
try:
820819
props['roles'] = self.instance.config.NEW_WEB_USER_ROLES
821820
del props['__time']
822821
self.userid = cl.create(**props)
823822
# clear the props from the otk database
824823
self.db.otks.destroy(otk)
825824
self.db.commit()
826-
# except (ValueError, KeyError), message:
827-
# self.error_message.append(str(message))
828-
# return
825+
except (ValueError, KeyError), message:
826+
self.error_message.append(str(message))
827+
return
829828

830829
# log the new user in
831830
self.user = cl.get(self.userid, 'username')
@@ -866,17 +865,16 @@ def passResetAction(self):
866865
newpw = ''.join([random.choice(self.chars) for x in range(8)])
867866

868867
cl = self.db.user
869-
# XXX we need to make the "default" page be able to display errors!
870-
# try:
871-
if 1:
868+
# XXX we need to make the "default" page be able to display errors!
869+
try:
872870
# set the password
873871
cl.set(uid, password=password.Password(newpw))
874872
# clear the props from the otk database
875873
self.db.otks.destroy(otk)
876874
self.db.commit()
877-
# except (ValueError, KeyError), message:
878-
# self.error_message.append(str(message))
879-
# return
875+
except (ValueError, KeyError), message:
876+
self.error_message.append(str(message))
877+
return
880878

881879
# user info
882880
address = self.db.user.get(uid, 'address')
@@ -944,22 +942,18 @@ def editItemAction(self):
944942
See parsePropsFromForm and _editnodes for special variables
945943
'''
946944
# parse the props from the form
947-
# XXX reinstate exception handling
948-
# try:
949-
if 1:
945+
try:
950946
props, links = self.parsePropsFromForm()
951-
# except (ValueError, KeyError), message:
952-
# self.error_message.append(_('Error: ') + str(message))
953-
# return
947+
except (ValueError, KeyError), message:
948+
self.error_message.append(_('Error: ') + str(message))
949+
return
954950

955951
# handle the props
956-
# XXX reinstate exception handling
957-
# try:
958-
if 1:
952+
try:
959953
message = self._editnodes(props, links)
960-
# except (ValueError, KeyError, IndexError), message:
961-
# self.error_message.append(_('Error: ') + str(message))
962-
# return
954+
except (ValueError, KeyError, IndexError), message:
955+
self.error_message.append(_('Error: ') + str(message))
956+
return
963957

964958
# commit now that all the tricky stuff is done
965959
self.db.commit()
@@ -999,34 +993,27 @@ def newItemAction(self):
999993
special form values.
1000994
'''
1001995
# parse the props from the form
1002-
# XXX reinstate exception handling
1003-
# try:
1004-
if 1:
996+
try:
1005997
props, links = self.parsePropsFromForm()
1006-
# except (ValueError, KeyError), message:
1007-
# self.error_message.append(_('Error: ') + str(message))
1008-
# return
998+
except (ValueError, KeyError), message:
999+
self.error_message.append(_('Error: ') + str(message))
1000+
return
10091001

10101002
# handle the props - edit or create
1011-
# XXX reinstate exception handling
1012-
# try:
1013-
if 1:
1014-
# create the context here
1015-
# cn = self.classname
1016-
# nid = self._createnode(cn, props[(cn, None)])
1017-
# del props[(cn, None)]
1018-
1003+
try:
10191004
# when it hits the None element, it'll set self.nodeid
1020-
messages = self._editnodes(props, links) #, {(cn, None): nid})
1005+
messages = self._editnodes(props, links)
10211006

1022-
# except (ValueError, KeyError, IndexError), message:
1023-
# # these errors might just be indicative of user dumbness
1024-
# self.error_message.append(_('Error: ') + str(message))
1025-
# return
1007+
except (ValueError, KeyError, IndexError), message:
1008+
# these errors might just be indicative of user dumbness
1009+
self.error_message.append(_('Error: ') + str(message))
1010+
return
10261011

10271012
# commit now that all the tricky stuff is done
10281013
self.db.commit()
10291014

1015+
print '%s%s%s?@ok_message=%s'%(self.base, self.classname,
1016+
self.nodeid, urllib.quote(messages))
10301017
# redirect to the new item's page
10311018
raise Redirect, '%s%s%s?@ok_message=%s'%(self.base, self.classname,
10321019
self.nodeid, urllib.quote(messages))

0 commit comments

Comments
 (0)