Use the the slug as the UUID instead of a newly generated UUID
authorxray7224 <jessica@megworld.co.uk>
Mon, 2 Sep 2013 15:22:24 +0000 (16:22 +0100)
committerJessica Tallon <jessica@megworld.co.uk>
Tue, 22 Jul 2014 22:13:14 +0000 (23:13 +0100)
mediagoblin/db/models.py
mediagoblin/federation/views.py

index 925f0d24e9597add7017fb5faa11a5696e24284a..ca4efdd17627579333753399293054fa82db39ff 100644 (file)
@@ -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
             )
 
index 3fe5b3b5899297868c0d52cf18091b39640073de..0108294282e5d15a5815b66b3b48654b832e7839 100644 (file)
@@ -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)