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>
This commit is contained in:
@@ -76,7 +76,7 @@ def submit_start(request):
|
||||
|
||||
entry.license = unicode(request.form.get('license', "")) or None
|
||||
|
||||
entry.uploader = request.user._id
|
||||
entry.uploader = request.user.id
|
||||
|
||||
# Process the user's folksonomy "tags"
|
||||
entry.tags = convert_to_tag_list_of_dicts(
|
||||
@@ -121,7 +121,7 @@ def submit_start(request):
|
||||
process_media = registry.tasks[ProcessMedia.name]
|
||||
try:
|
||||
process_media.apply_async(
|
||||
[unicode(entry._id)], {},
|
||||
[unicode(entry.id)], {},
|
||||
task_id=task_id)
|
||||
except BaseException as exc:
|
||||
# The purpose of this section is because when running in "lazy"
|
||||
@@ -132,7 +132,7 @@ def submit_start(request):
|
||||
#
|
||||
# ... not completely the diaper pattern because the
|
||||
# exception is re-raised :)
|
||||
mark_entry_failed(entry._id, exc)
|
||||
mark_entry_failed(entry.id, exc)
|
||||
# re-raise the exception
|
||||
raise
|
||||
|
||||
@@ -198,12 +198,12 @@ def add_collection(request, media=None):
|
||||
collection.title = unicode(request.form['title'])
|
||||
|
||||
collection.description = unicode(request.form.get('description'))
|
||||
collection.creator = request.user._id
|
||||
collection.creator = request.user.id
|
||||
collection.generate_slug()
|
||||
|
||||
# Make sure this user isn't duplicating an existing collection
|
||||
existing_collection = request.db.Collection.find_one({
|
||||
'creator': request.user._id,
|
||||
'creator': request.user.id,
|
||||
'title':collection.title})
|
||||
|
||||
if existing_collection:
|
||||
|
||||
Reference in New Issue
Block a user