Mercurial > p > roundup > code
diff roundup/roundupdb.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 | b3abda04a690 |
| children | 2724d14f0c42 |
line wrap: on
line diff
--- 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
