changeset 690:e8ccec07515b

Refactored user search by mail address.
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Tue, 16 May 2006 00:15:55 +0200
parents 7f11b74d0506
children f18b06c790d4
files MoinMoin/user.py MoinMoin/userform.py
diffstat 2 files changed, 11 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/user.py	Mon May 15 22:40:26 2006 +0200
+++ b/MoinMoin/user.py	Tue May 16 00:15:55 2006 +0200
@@ -33,6 +33,13 @@
     userlist = [f for f in files if user_re.match(f)]
     return userlist
 
+def get_by_email_address(request, email_address):
+    """ Searches for a user with a particular e-mail address and
+        returns it."""
+    for uid in getUserList(request):
+        theuser = User(request, uid)
+        if theuser.valid and theuser.email.lower() == email_address.lower():
+            return theuser
 
 def getUserId(request, searchName):
     """
--- a/MoinMoin/userform.py	Mon May 15 22:40:26 2006 +0200
+++ b/MoinMoin/userform.py	Tue May 16 00:15:55 2006 +0200
@@ -76,12 +76,10 @@
             except KeyError:
                 return _("Please provide a valid email address!")
     
-            users = user.getUserList(self.request)
-            for uid in users:
-                theuser = user.User(self.request, uid)
-                if theuser.valid and theuser.email.lower() == email:
-                    msg = theuser.mailAccountData()
-                    return wikiutil.escape(msg)
+            u = user.get_by_email_address(self.request, email)
+            if u:
+                msg = u.mailAccountData()
+                return wikiutil.escape(msg)
 
             return _("Found no account matching the given email address '%(email)s'!") % {'email': wikiutil.escape(email)}