Mercurial > p > roundup > code
comparison roundup/cgi/client.py @ 1790:c8614db86be2
Extract confirm_registration() from client to roundupdb...
...for use in mailgw registration confirmation.
| author | Johannes Gijsbers <jlgijsbers@users.sourceforge.net> |
|---|---|
| date | Sat, 06 Sep 2003 07:27:30 +0000 |
| parents | fdaa0b751355 |
| children | bcdb2ed730b5 |
comparison
equal
deleted
inserted
replaced
| 1789:8c05f8a93a36 | 1790:c8614db86be2 |
|---|---|
| 1 # $Id: client.py,v 1.132 2003-08-28 04:46:39 richard Exp $ | 1 # $Id: client.py,v 1.133 2003-09-06 07:27:30 jlgijsbers Exp $ |
| 2 | 2 |
| 3 __doc__ = """ | 3 __doc__ = """ |
| 4 WWW request handler (also used in the stand-alone server). | 4 WWW request handler (also used in the stand-alone server). |
| 5 """ | 5 """ |
| 6 | 6 |
| 838 return 0 | 838 return 0 |
| 839 | 839 |
| 840 def confRegoAction(self): | 840 def confRegoAction(self): |
| 841 ''' Grab the OTK, use it to load up the new user details | 841 ''' Grab the OTK, use it to load up the new user details |
| 842 ''' | 842 ''' |
| 843 # pull the rego information out of the otk database | |
| 844 otk = self.form['otk'].value | |
| 845 props = self.db.otks.getall(otk) | |
| 846 for propname, proptype in self.db.user.getprops().items(): | |
| 847 value = props.get(propname, None) | |
| 848 if value is None: | |
| 849 pass | |
| 850 elif isinstance(proptype, hyperdb.Date): | |
| 851 props[propname] = date.Date(value) | |
| 852 elif isinstance(proptype, hyperdb.Interval): | |
| 853 props[propname] = date.Interval(value) | |
| 854 elif isinstance(proptype, hyperdb.Password): | |
| 855 props[propname] = password.Password() | |
| 856 props[propname].unpack(value) | |
| 857 | |
| 858 # re-open the database as "admin" | |
| 859 if self.user != 'admin': | |
| 860 self.opendb('admin') | |
| 861 | |
| 862 # create the new user | |
| 863 cl = self.db.user | |
| 864 # XXX we need to make the "default" page be able to display errors! | |
| 865 try: | 843 try: |
| 866 props['roles'] = self.instance.config.NEW_WEB_USER_ROLES | 844 # pull the rego information out of the otk database |
| 867 del props['__time'] | 845 self.userid = self.db.confirm_registration(self.form['otk'].value) |
| 868 self.userid = cl.create(**props) | |
| 869 # clear the props from the otk database | |
| 870 self.db.otks.destroy(otk) | |
| 871 self.db.commit() | |
| 872 except (ValueError, KeyError), message: | 846 except (ValueError, KeyError), message: |
| 847 # XXX: we need to make the "default" page be able to display errors! | |
| 873 self.error_message.append(str(message)) | 848 self.error_message.append(str(message)) |
| 874 return | 849 return |
| 875 | 850 |
| 876 # log the new user in | 851 # log the new user in |
| 877 self.user = cl.get(self.userid, 'username') | 852 self.user = self.db.user.get(self.userid, 'username') |
| 878 # re-open the database for real, using the user | 853 # re-open the database for real, using the user |
| 879 self.opendb(self.user) | 854 self.opendb(self.user) |
| 880 | 855 |
| 881 # if we have a session, update it | 856 # if we have a session, update it |
| 882 if hasattr(self, 'session'): | 857 if hasattr(self, 'session'): |
