diff options
author | Nicolás Reynolds <fauno@kiwwwi.com.ar> | 2011-12-04 23:07:59 -0300 |
---|---|---|
committer | Nicolás Reynolds <fauno@kiwwwi.com.ar> | 2011-12-04 23:07:59 -0300 |
commit | 988c2c6d400b3721464c2891891807d504b076b0 (patch) | |
tree | 013dc3d676edad701d0d3bbd239bc2df0cdf76b4 /devel/utils.py | |
parent | 60a1fc6cc4cef0b9eed58ea4f0ca003b76ec382a (diff) | |
parent | 183c4d9cefa95f46c3fa3a6936f837542426eac2 (diff) |
Merge branch 'master' of ssh://gparabola/parabolaweb
Conflicts:
local_settings.py.example
media/archweb.css
packages/templatetags/package_extras.py
public/views.py
templates/packages/details.html
templates/packages/flag.html
templates/packages/flag_confirmed.html
templates/packages/flagged.html
templates/packages/search.html
templates/public/download.html
templates/todolists/view.html
Diffstat (limited to 'devel/utils.py')
-rw-r--r-- | devel/utils.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/devel/utils.py b/devel/utils.py index d7a154a8..62b12cd5 100644 --- a/devel/utils.py +++ b/devel/utils.py @@ -47,6 +47,7 @@ SELECT pr.user_id, COUNT(*), COUNT(p.flag_date) class UserFinder(object): def __init__(self): self.cache = {} + self.username_cache = {} @staticmethod def user_email(name, email): @@ -111,7 +112,22 @@ class UserFinder(object): self.cache[userstring] = user return user + def find_by_username(self, username): + if not username: + return None + if username in self.username_cache: + return self.username_cache[username] + + try: + user = User.objects.get(username=username) + except User.DoesNotExist: + user = None + + self.username_cache[username] = user + return user + def clear_cache(self): self.cache = {} + self.username_cache = {} # vim: set ts=4 sw=4 et: |