|
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 $ |
2 | 2 |
|
3 | 3 | __doc__ = """ |
4 | 4 | WWW request handler (also used in the stand-alone server). |
@@ -815,17 +815,16 @@ def confRegoAction(self): |
815 | 815 | # create the new user |
816 | 816 | cl = self.db.user |
817 | 817 | # XXX we need to make the "default" page be able to display errors! |
818 | | -# try: |
819 | | - if 1: |
| 818 | + try: |
820 | 819 | props['roles'] = self.instance.config.NEW_WEB_USER_ROLES |
821 | 820 | del props['__time'] |
822 | 821 | self.userid = cl.create(**props) |
823 | 822 | # clear the props from the otk database |
824 | 823 | self.db.otks.destroy(otk) |
825 | 824 | 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 |
829 | 828 |
|
830 | 829 | # log the new user in |
831 | 830 | self.user = cl.get(self.userid, 'username') |
@@ -866,17 +865,16 @@ def passResetAction(self): |
866 | 865 | newpw = ''.join([random.choice(self.chars) for x in range(8)]) |
867 | 866 |
|
868 | 867 | 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: |
872 | 870 | # set the password |
873 | 871 | cl.set(uid, password=password.Password(newpw)) |
874 | 872 | # clear the props from the otk database |
875 | 873 | self.db.otks.destroy(otk) |
876 | 874 | 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 |
880 | 878 |
|
881 | 879 | # user info |
882 | 880 | address = self.db.user.get(uid, 'address') |
@@ -944,22 +942,18 @@ def editItemAction(self): |
944 | 942 | See parsePropsFromForm and _editnodes for special variables |
945 | 943 | ''' |
946 | 944 | # parse the props from the form |
947 | | -# XXX reinstate exception handling |
948 | | -# try: |
949 | | - if 1: |
| 945 | + try: |
950 | 946 | 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 |
954 | 950 |
|
955 | 951 | # handle the props |
956 | | -# XXX reinstate exception handling |
957 | | -# try: |
958 | | - if 1: |
| 952 | + try: |
959 | 953 | 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 |
963 | 957 |
|
964 | 958 | # commit now that all the tricky stuff is done |
965 | 959 | self.db.commit() |
@@ -999,34 +993,27 @@ def newItemAction(self): |
999 | 993 | special form values. |
1000 | 994 | ''' |
1001 | 995 | # parse the props from the form |
1002 | | -# XXX reinstate exception handling |
1003 | | -# try: |
1004 | | - if 1: |
| 996 | + try: |
1005 | 997 | 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 |
1009 | 1001 |
|
1010 | 1002 | # 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: |
1019 | 1004 | # 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) |
1021 | 1006 |
|
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 |
1026 | 1011 |
|
1027 | 1012 | # commit now that all the tricky stuff is done |
1028 | 1013 | self.db.commit() |
1029 | 1014 |
|
| 1015 | + print '%s%s%s?@ok_message=%s'%(self.base, self.classname, |
| 1016 | + self.nodeid, urllib.quote(messages)) |
1030 | 1017 | # redirect to the new item's page |
1031 | 1018 | raise Redirect, '%s%s%s?@ok_message=%s'%(self.base, self.classname, |
1032 | 1019 | self.nodeid, urllib.quote(messages)) |
|
0 commit comments