From 570a60f8364dbd148fbd7b903a4422acbba6dfbc Mon Sep 17 00:00:00 2001 From: Eevee Date: Sat, 5 Dec 2009 19:48:35 -0800 Subject: [PATCH 1/1] Search for usernames literally, not with func.lower(). --- floof/controllers/art.py | 4 +--- floof/controllers/tag.py | 4 +--- floof/controllers/user_settings.py | 3 +-- floof/controllers/users.py | 4 +--- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/floof/controllers/art.py b/floof/controllers/art.py index ee1e4ad..bf928f0 100644 --- a/floof/controllers/art.py +++ b/floof/controllers/art.py @@ -18,7 +18,6 @@ import elixir import os.path import PIL import PIL.Image -from sqlalchemy import func from sqlalchemy.exceptions import IntegrityError from sqlalchemy.orm.exc import NoResultFound from wtforms.validators import ValidationError @@ -139,8 +138,7 @@ class ArtController(BaseController): def watchstream(self, name): """Watchstream for a certain user.""" try: - c.watching_user = User.query.filter(func.lower(User.name) == name) \ - .one() + c.watching_user = User.get_by(name=name) except NoResultFound: abort(404) diff --git a/floof/controllers/tag.py b/floof/controllers/tag.py index e57d0c5..730bf72 100644 --- a/floof/controllers/tag.py +++ b/floof/controllers/tag.py @@ -9,7 +9,6 @@ from floof.model import Art, ArtUser, ArtUserType, Tag, TagText, User from floof.lib.base import BaseController, render from floof.lib.dbhelpers import find_or_create from floof.lib import helpers as h -from sqlalchemy import func log = logging.getLogger(__name__) @@ -64,8 +63,7 @@ class TagController(BaseController): # Do work! if prefix: - target_user = User.query.filter(func.lower(User.name) == tag_text) \ - .one() + target_user = User.get_by(name=tag_text) # Special tag; at the moment, just a relationship if prefix == 'by': diff --git a/floof/controllers/user_settings.py b/floof/controllers/user_settings.py index 8d8adf0..de46e37 100644 --- a/floof/controllers/user_settings.py +++ b/floof/controllers/user_settings.py @@ -3,7 +3,6 @@ import logging import elixir from pylons import request, response, session, tmpl_context as c from pylons.controllers.util import abort, redirect_to -from sqlalchemy import func from sqlalchemy.orm.exc import NoResultFound import floof.lib.helpers as h @@ -22,7 +21,7 @@ class UserSettingsController(BaseController): `type`, and `add_remove` as parameters. """ try: - user = User.query.filter(func.lower(User.name) == name).one() + user = User.get_by(name=name) except NoResultFound: abort(404) diff --git a/floof/controllers/users.py b/floof/controllers/users.py index 1a79c15..7c24c0f 100644 --- a/floof/controllers/users.py +++ b/floof/controllers/users.py @@ -2,7 +2,6 @@ import logging from pylons import request, response, session, tmpl_context as c from pylons.controllers.util import abort, redirect_to -from sqlalchemy import func from sqlalchemy.orm.exc import NoResultFound from floof.lib.base import BaseController, render @@ -24,8 +23,7 @@ class UsersController(BaseController): """Userpage.""" try: - c.this_user = User.query.filter(func.lower(User.name) == name) \ - .one() + c.this_user = User.get_by(name=name) except NoResultFound: abort(404) -- 2.7.4