Mercurial > p > roundup > code
changeset 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 | 8c05f8a93a36 |
| children | bcdb2ed730b5 |
| files | roundup/backends/back_anydbm.py roundup/cgi/client.py roundup/roundupdb.py |
| diffstat | 3 files changed, 43 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/roundup/backends/back_anydbm.py Fri Sep 05 21:05:18 2003 +0000 +++ b/roundup/backends/back_anydbm.py Sat Sep 06 07:27:30 2003 +0000 @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -#$Id: back_anydbm.py,v 1.124 2003-09-04 00:47:01 richard Exp $ +#$Id: back_anydbm.py,v 1.125 2003-09-06 07:27:30 jlgijsbers Exp $ ''' This module defines a backend that saves the hyperdatabase in a database chosen by anydbm. It is guaranteed to always be available in python @@ -87,8 +87,10 @@ # reindex the db if necessary if self.indexer.should_reindex(): self.reindex() + self.figure_curuserid() - # figure the "curuserid" + def figure_curuserid(self): + """Figure out the 'curuserid'.""" if self.journaltag is None: self.curuserid = None elif self.journaltag == 'admin':
--- a/roundup/cgi/client.py Fri Sep 05 21:05:18 2003 +0000 +++ b/roundup/cgi/client.py Sat Sep 06 07:27:30 2003 +0000 @@ -1,4 +1,4 @@ -# $Id: client.py,v 1.132 2003-08-28 04:46:39 richard Exp $ +# $Id: client.py,v 1.133 2003-09-06 07:27:30 jlgijsbers Exp $ __doc__ = """ WWW request handler (also used in the stand-alone server). @@ -840,41 +840,16 @@ def confRegoAction(self): ''' Grab the OTK, use it to load up the new user details ''' - # pull the rego information out of the otk database - otk = self.form['otk'].value - props = self.db.otks.getall(otk) - for propname, proptype in self.db.user.getprops().items(): - value = props.get(propname, None) - if value is None: - pass - elif isinstance(proptype, hyperdb.Date): - props[propname] = date.Date(value) - elif isinstance(proptype, hyperdb.Interval): - props[propname] = date.Interval(value) - elif isinstance(proptype, hyperdb.Password): - props[propname] = password.Password() - props[propname].unpack(value) - - # re-open the database as "admin" - if self.user != 'admin': - self.opendb('admin') - - # create the new user - cl = self.db.user -# XXX we need to make the "default" page be able to display errors! 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() + # pull the rego information out of the otk database + self.userid = self.db.confirm_registration(self.form['otk'].value) except (ValueError, KeyError), message: + # XXX: we need to make the "default" page be able to display errors! self.error_message.append(str(message)) return - + # log the new user in - self.user = cl.get(self.userid, 'username') + self.user = self.db.user.get(self.userid, 'username') # re-open the database for real, using the user self.opendb(self.user)
--- a/roundup/roundupdb.py Fri Sep 05 21:05:18 2003 +0000 +++ b/roundup/roundupdb.py Sat Sep 06 07:27:30 2003 +0000 @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: roundupdb.py,v 1.86 2003-04-27 02:24:37 richard Exp $ +# $Id: roundupdb.py,v 1.87 2003-09-06 07:27:30 jlgijsbers Exp $ __doc__ = """ Extending hyperdb with types specific to issue-tracking. @@ -27,6 +27,8 @@ from rfc2822 import encode_header +from roundup import password, date + # if available, use the 'email' module, otherwise fallback to 'rfc822' try : from email.Utils import formataddr as straddr @@ -70,6 +72,36 @@ timezone = 0 return timezone + def confirm_registration(self, otk): + props = self.otks.getall(otk) + for propname, proptype in self.user.getprops().items(): + value = props.get(propname, None) + if value is None: + pass + elif isinstance(proptype, hyperdb.Date): + props[propname] = date.Date(value) + elif isinstance(proptype, hyperdb.Interval): + props[propname] = date.Interval(value) + elif isinstance(proptype, hyperdb.Password): + props[propname] = password.Password() + props[propname].unpack(value) + + # tag new user creation with 'admin' + self.journaltag = 'admin' + self.figure_curuserid() + + # create the new user + cl = self.user + + props['roles'] = self.config.NEW_WEB_USER_ROLES + del props['__time'] + userid = cl.create(**props) + # clear the props from the otk database + self.otks.destroy(otk) + self.commit() + + return userid + class MessageSendError(RuntimeError): pass
