changeset 837:f0dceb963342

user: minor refactorings in lookup functions
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 03 Sep 2011 23:45:18 +0200
parents 942b53b4e095
children ff63eb0afd24
files MoinMoin/user.py
diffstat 1 files changed, 16 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/user.py	Sat Sep 03 23:33:02 2011 +0200
+++ b/MoinMoin/user.py	Sat Sep 03 23:45:18 2011 +0200
@@ -95,8 +95,8 @@
     return flaskg.unprotected_storage
 
 
-def get_revs_by_filter(**q):
-    """ Searches for a user with a given filter """
+def search_users(**q):
+    """ Searches for a users with given query keys/values """
     q.update(wikiname=app.cfg.interwikiname) # XXX for now, search only users of THIS wiki
                                              # maybe add option to not index wiki users separately,
                                              # but share them in the index also
@@ -111,14 +111,14 @@
     :rtype: list
     :returns: all user IDs
     """
-    revs = get_revs_by_filter()
-    return [rev[UUID] for rev in revs]
+    docs = search_users()
+    return [doc[UUID] for doc in docs]
 
 def get_by_email(email):
     """ Searches for an user with a particular e-mail address and returns it. """
-    revs = get_revs_by_filter(email=email)
-    if revs:
-        return User(revs[0][UUID])
+    docs = search_users(email=email)
+    if docs:
+        return User(docs[0][UUID])
 
 def get_by_openid(openid):
     """
@@ -129,9 +129,9 @@
     :returns: the user whose openid is this one
     :rtype: user object or None
     """
-    revs = get_revs_by_filter(openid=openid)
-    if revs:
-        return User(revs[0][UUID])
+    docs = search_users(openid=openid)
+    if docs:
+        return User(docs[0][UUID])
 
 def getName(uuid):
     """ Get the name for a specific uuid.
@@ -140,9 +140,9 @@
     :rtype: string
     :returns: the corresponding user name or None
     """
-    revs = get_revs_by_filter(uuid=uuid)
-    if revs:
-        return revs[0][NAME]
+    docs = search_users(uuid=uuid)
+    if docs:
+        return docs[0][NAME]
 
 def getUserId(name):
     """ Get the user ID for a specific user NAME.
@@ -151,9 +151,9 @@
     :rtype: unicode
     :returns: the corresponding user ID or None
     """
-    revs = get_revs_by_filter(name_exact=name)
-    if revs:
-        return revs[0][UUID]
+    docs = search_users(name_exact=name)
+    if docs:
+        return docs[0][UUID]
 
 def get_editor(userid, addr, hostname):
     """ Return a tuple of type id and string or Page object