diff options
author | Sebastian Spaeth <Sebastian@SSpaeth.de> | 2012-11-30 10:49:06 +0100 |
---|---|---|
committer | Sebastian Spaeth <Sebastian@SSpaeth.de> | 2012-12-21 00:30:48 +0100 |
commit | 5c2b84869fe3f4bfe41a31ff3968bb13c6d7f868 (patch) | |
tree | 6b2ec753c753745ee7964b9544835619b915d0f2 /mediagoblin/auth/views.py | |
parent | 7e55bcb898d37010a5e9bd8a666cd3ddfa63de33 (diff) | |
download | mediagoblin-5c2b84869fe3f4bfe41a31ff3968bb13c6d7f868.tar.lz mediagoblin-5c2b84869fe3f4bfe41a31ff3968bb13c6d7f868.tar.xz mediagoblin-5c2b84869fe3f4bfe41a31ff3968bb13c6d7f868.zip |
Move DBModel._id -> DBModel.id
We were refering to model._id in most of the code base as this is
what Mongo uses. However, each use of _id required a) fixup of queries:
e.g. what we did in our find() and find_one() functions moving all
'_id' to 'id'. It also required using AliasFields to make the ._id
attribute available. This all means lots of superfluous fixing and
transitioning in a SQL world.
It will also not work in the long run. Much newer code already refers
to the objects by model.id (e.g. in the oauth plugin), which will break
with Mongo. So let's be honest, rip out the _id mongoism and live with
.id as the one canonical way to address objects.
This commit modifies all users and providers of model._id to use
model.id instead. This patch works with or without Mongo removed first,
but will break Mongo usage (even more than before)
I have not bothered to fixup db.mongo.* and db.sql.convert
(which converts from Mongo to SQL)
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Diffstat (limited to 'mediagoblin/auth/views.py')
-rw-r--r-- | mediagoblin/auth/views.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/mediagoblin/auth/views.py b/mediagoblin/auth/views.py index 5b77c122..31f50fa6 100644 --- a/mediagoblin/auth/views.py +++ b/mediagoblin/auth/views.py @@ -90,7 +90,7 @@ def register(request): user.save(validate=True) # log the user in - request.session['user_id'] = unicode(user._id) + request.session['user_id'] = unicode(user.id) request.session.save() # send verification email @@ -125,7 +125,7 @@ def login(request): if user and user.check_login(request.form['password']): # set up login in session - request.session['user_id'] = unicode(user._id) + request.session['user_id'] = unicode(user.id) request.session.save() if request.form.get('next'): @@ -167,7 +167,7 @@ def verify_email(request): return render_404(request) user = request.db.User.find_one( - {'_id': ObjectId(unicode(request.GET['userid']))}) + {'id': ObjectId(unicode(request.GET['userid']))}) if user and user.verification_key == unicode(request.GET['token']): user.status = u'active' @@ -308,7 +308,7 @@ def verify_forgot_password(request): # check if it's a valid Id try: user = request.db.User.find_one( - {'_id': ObjectId(unicode(formdata_userid))}) + {'id': ObjectId(unicode(formdata_userid))}) except InvalidId: return render_404(request) |