diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2012-11-15 01:00:13 -0500 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2012-11-15 01:00:13 -0500 |
commit | aa2836cb3859e05e9524def5ec37706e3299205c (patch) | |
tree | ca1de8b399b578aeb5b86490451a136d9986ad1a /devel/utils.py | |
parent | 12984bca989485430d3a1be9ea35d3f61239b28f (diff) | |
parent | c3ebf7deae0bb04f1637e9a52e7f9f38d454fec7 (diff) |
Merge tag 'release_2012-02-11'
Quick release
Conflicts:
requirements.txt
requirements_prod.txt
Diffstat (limited to 'devel/utils.py')
-rw-r--r-- | devel/utils.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/devel/utils.py b/devel/utils.py index 62b12cd5..ec035d13 100644 --- a/devel/utils.py +++ b/devel/utils.py @@ -48,6 +48,7 @@ class UserFinder(object): def __init__(self): self.cache = {} self.username_cache = {} + self.email_cache = {} @staticmethod def user_email(name, email): @@ -110,6 +111,7 @@ class UserFinder(object): pass self.cache[userstring] = user + self.email_cache[email] = user return user def find_by_username(self, username): @@ -126,8 +128,27 @@ class UserFinder(object): self.username_cache[username] = user return user + def find_by_email(self, email): + if not email: + return None + if email in self.email_cache: + return self.email_cache[email] + + user = None + try: + user = self.user_email(None, email) + except User.DoesNotExist: + try: + user = self.profile_email(None, email) + except User.DoesNotExist: + pass + + self.email_cache[email] = user + return user + def clear_cache(self): self.cache = {} self.username_cache = {} + self.email_cache = {} # vim: set ts=4 sw=4 et: |