1. David Bennett
  2. django-private-media


David Bennett  committed af119e9

Don't mess with url quoting until I have a test showing that I actually need it...

  • Participants
  • Parent commits 5487510
  • Branches default

Comments (0)

Files changed (3)

File private_media/fields.py

View file
  • Ignore whitespace
 from django.core.urlresolvers import reverse
 from django.db.models.fields import files
 from private_media.conf import settings
-from private_media.utils import encode_key, urlquote
+from private_media.utils import encode_key
 class PrivateFieldFile(files.FieldFile):
         key = (
-            urlquote(self.instance.pk, safe=''),
+            self.instance.pk,
         if settings.PRIVATE_MEDIA_ENCODE_URL:

File private_media/utils.py

View file
  • Ignore whitespace
 from base64 import urlsafe_b64encode, urlsafe_b64decode
 from itertools import izip, cycle
-from urllib import unquote
-from django.utils.http import urlquote, force_unicode, smart_str, allow_lazy
 from private_media.conf import settings
-assert urlquote
 def xor_crypt_string(data, key=None):
 def decode_key(key):
     return xor_crypt_string(urlsafe_b64decode(str(key) + '=='))
-def urlunquote(quoted_url):
-    """
-    A wrapper for Python's urllib.unquote() function that can operate on
-    the result of django.utils.http.urlquote().
-    """
-    return force_unicode(unquote(smart_str(quoted_url)))
-urlunquote = allow_lazy(urlunquote, unicode)

File private_media/views.py

View file
  • Ignore whitespace
 from django.http import Http404
 from django.views.static import serve
 from private_media.conf import settings
-from private_media.utils import decode_key, urlunquote
+from private_media.utils import decode_key
 def get_file(request, content_type_id, object_pk, field_name, file_name):
         key = decode_key(enc_key)
         content_type_id, object_pk, field_name = key.split('/', 2)
-        object_pk = urlunquote(object_pk)
     except Exception, e:
         raise Http404(e if settings.DEBUG else 'File not found.')
     return get_file(request, content_type_id, object_pk, field_name, file_name)