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.
This commit is contained in:
Elrond 2012-01-28 00:24:09 +01:00
parent dd0799ad0a
commit 84812db59d

View File

@ -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']):