from mediagoblin.tools import url
from mediagoblin.db.mixin import UserMixin, MediaEntryMixin, MediaCommentMixin
+
+class MongoPK(object):
+ """An alias for the _id primary key"""
+ def __get__(self, instance, cls):
+ return instance['_id']
+ def __set__(self, instance, val):
+ instance['_id'] = val
+ def __delete__(self, instance):
+ del instance['_id']
+
+
###################
# Custom validators
###################
'status': u'needs_email_verification',
'is_admin': False}
+ id = MongoPK()
+
class MediaEntry(Document, MediaEntryMixin):
"""
'created': datetime.datetime.utcnow,
'state': u'unprocessed'}
+ id = MongoPK()
+
def get_comments(self, ascending=False):
if ascending:
order = ASCENDING
# create entry and save in database
entry = request.db.MediaEntry()
- entry['_id'] = ObjectId()
+ entry.id = ObjectId()
entry.media_type = unicode(media_type)
entry.title = (
unicode(request.POST['title'])