changeset 2142:2e205b784aed

fix moin account-password falling over missing EMAIL key
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 03 Oct 2013 14:52:35 +0200
parents e58f8d21b373
children ed73c69d80c0
files MoinMoin/script/account/resetpw.py
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/script/account/resetpw.py	Sun Sep 15 14:02:19 2013 +0200
+++ b/MoinMoin/script/account/resetpw.py	Thu Oct 03 14:52:35 2013 +0200
@@ -13,7 +13,9 @@
 from flask import current_app as app
 from flask.ext.script import Command, Option
 
-from MoinMoin.constants.keys import ITEMID, NAME, NAME_EXACT, EMAIL
+from MoinMoin.constants.keys import (
+    ITEMID, NAME, NAME_EXACT, EMAIL, EMAIL_UNVALIDATED,
+)
 from MoinMoin import user
 from MoinMoin.app import before_wiki
 
@@ -103,7 +105,13 @@
         total = len(uids_metas)
         for nr, (uid, meta) in enumerate(uids_metas, start=1):
             name = meta[NAME]
-            email = meta[EMAIL]
+            email = meta.get(EMAIL)
+            if email is None:
+                email = meta.get(EMAIL_UNVALIDATED)
+                if email is None:
+                    raise ValueError("neither EMAIL nor EMAIL_UNVALIDATED key is present in user profile metadata of uid %r name %r" % (uid, name))
+                else:
+                    email += '[email_unvalidated]'
             try:
                 set_password(uid, password, notify=notify, skip_invalid=skip_invalid,
                              subject=subject, text=text)