From d461fbe5cb20ed56c3c1e3696464c3d323e5b4b0 Mon Sep 17 00:00:00 2001 From: xray7224 Date: Mon, 2 Sep 2013 16:22:24 +0100 Subject: [PATCH] Use the the slug as the UUID instead of a newly generated UUID --- mediagoblin/db/models.py | 7 +------ mediagoblin/federation/views.py | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py index 925f0d24..ca4efdd1 100644 --- a/mediagoblin/db/models.py +++ b/mediagoblin/db/models.py @@ -236,11 +236,6 @@ class NonceTimestamp(Base): nonce = Column(Unicode, nullable=False, primary_key=True) timestamp = Column(DateTime, nullable=False, primary_key=True) - -def create_uuid(): - """ Creates a new uuid which is suitable for use in a URL """ - return base64.urlsafe_b64encode(uuid.uuid4().bytes).strip("=") - class MediaEntry(Base, MediaEntryMixin): """ TODO: Consider fetching the media_files using join @@ -445,7 +440,7 @@ class MediaEntry(Base, MediaEntryMixin): id = request.urlgen( "mediagoblin.federation.object", objectType=self.objectType, - uuid=self.uuid, + uuid=self.slug, qualified=True ) diff --git a/mediagoblin/federation/views.py b/mediagoblin/federation/views.py index 3fe5b3b5..01082942 100644 --- a/mediagoblin/federation/views.py +++ b/mediagoblin/federation/views.py @@ -49,7 +49,7 @@ def object(request): # not sure why this is 404, maybe ask evan. Maybe 400? return json_response({"error": error}, status=404) - media = MediaEntry.query.filter_by(uuid=uuid).first() + media = MediaEntry.query.filter_by(slug=uuid).first() if media is None: # no media found with that uuid error = "Can't find a {0} with ID = {1}".format(objectType, uuid) -- 2.25.1