From 84812db59dcc7ba476191678a8bb0e1829f3f607 Mon Sep 17 00:00:00 2001 From: Elrond Date: Sat, 28 Jan 2012 00:24:09 +0100 Subject: [PATCH] Change user search from .one to .fine_one. When searching for a user by username, there can either be no result or one result. There is a unique constraint on the db. .one in mongokit raises an error for more than one result. But that can't happen anyway. So no problem. .one in sqlalchemy raises an error for more than one, but that's not a problem anyway. It also raises an error for no result. But no result is handled by the code anyway, so no need to raise an exception. .find_one doesn't raise an exception for more than one result (no problem anyway) and just returns None for no result. The later is handled by the code. --- mediagoblin/auth/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediagoblin/auth/views.py b/mediagoblin/auth/views.py index e18469b9..46c937b0 100644 --- a/mediagoblin/auth/views.py +++ b/mediagoblin/auth/views.py @@ -120,7 +120,7 @@ def login(request): login_failed = False if request.method == 'POST' and login_form.validate(): - user = request.db.User.one( + user = request.db.User.find_one( {'username': request.POST['username'].lower()}) if user and user.check_login(request.POST['password']):