diff options
author | Jessica Tallon <tsyesika@tsyesika.se> | 2015-08-24 18:28:41 +0200 |
---|---|---|
committer | Jessica Tallon <tsyesika@tsyesika.se> | 2015-08-24 21:07:06 +0200 |
commit | b4997540dcc7b75441e9b10ee6dcac32cc2708be (patch) | |
tree | e543baf0acc77214c44bad9f826d9187459539a9 /mediagoblin/api/views.py | |
parent | e9bb5879f772e4d546aadb4bb6f935c7c55b8000 (diff) | |
download | mediagoblin-b4997540dcc7b75441e9b10ee6dcac32cc2708be.tar.lz mediagoblin-b4997540dcc7b75441e9b10ee6dcac32cc2708be.tar.xz mediagoblin-b4997540dcc7b75441e9b10ee6dcac32cc2708be.zip |
Fix some unit tests and bugs
This fixes a lot of the issues with the LocalUser changes that were
merged recently. There was a problem where the attributes of LocalUser
were not being eagerly loaded and because the Session was detached an
exception was being raised when they were accessed.
This also fixes some typo's which were introduced.
Finally this adds a temporary fix for a potential SQLAlchemy bug, this
is a bug where doing:
User.query.filter(LocalUser.username == "some_username").first()
does NOT yeild a user with the username "some_username" but all users
on the site. The temp fix is to just query the LocalUser, this should
be resolved when bug is confirmed and fixed upstream.
Diffstat (limited to 'mediagoblin/api/views.py')
-rw-r--r-- | mediagoblin/api/views.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/mediagoblin/api/views.py b/mediagoblin/api/views.py index 35f8405c..9c2876c2 100644 --- a/mediagoblin/api/views.py +++ b/mediagoblin/api/views.py @@ -45,7 +45,7 @@ def get_profile(request): can be found then this function returns a (None, None). """ username = request.matchdict["username"] - user = User.query.filter(LocalUser.username==username).first() + user = LocalUser.query.filter(LocalUser.username==username).first() if user is None: return None, None @@ -94,7 +94,7 @@ def user_endpoint(request): def uploads_endpoint(request): """ Endpoint for file uploads """ username = request.matchdict["username"] - requested_user = User.query.filter(LocalUser.username==username).first() + requested_user = LocalUser.query.filter(LocalUser.username==username).first() if requested_user is None: return json_error("No such 'user' with id '{0}'".format(username), 404) @@ -142,7 +142,7 @@ def inbox_endpoint(request, inbox=None): inbox: allows you to pass a query in to limit inbox scope """ username = request.matchdict["username"] - user = User.query.filter(LocalUser.username==username).first() + user = LocalUser.query.filter(LocalUser.username==username).first() if user is None: return json_error("No such 'user' with id '{0}'".format(username), 404) @@ -225,7 +225,7 @@ def inbox_major_endpoint(request): def feed_endpoint(request, outbox=None): """ Handles the user's outbox - /api/user/<username>/feed """ username = request.matchdict["username"] - requested_user = User.query.filter(LocalUser.username==username).first() + requested_user = LocalUser.query.filter(LocalUser.username==username).first() # check if the user exists if requested_user is None: @@ -747,7 +747,7 @@ def lrdd_lookup(request): username, host = resource.split("@", 1) # Now lookup the user - user = User.query.filter(LocalUser.username==username).first() + user = LocalUser.query.filter(LocalUser.username==username).first() if user is None: return json_error( |