Commits

David Bennett committed 632bd35

Some tweaks to variable names.

Comments (0)

Files changed (2)

private_media/handlers.py

 from django.http import HttpResponse
 
 
-def nginx(request, file):
+def nginx(request, file_field):
     response = HttpResponse()
     # Let nginx figure out the Content-Type
     response['Content-Type'] = ''
     response['X-Accel-Redirect'] = urljoin(
-        settings.PRIVATE_MEDIA_URL, file.name)
+        settings.PRIVATE_MEDIA_URL, file_field.name)
     return response
 
 
-def xsendfile(request, file):
+def xsendfile(request, file_field):
     response = HttpResponse()
-    mimetype, encoding = mimetypes.guess_type(file.name)
+    mimetype, encoding = mimetypes.guess_type(file_field.name)
     response['Content-Type'] = mimetype or 'application/octet-stream'
-    response["X-SendFile"] = file.path
+    response["X-SendFile"] = file_field.path
     return response

private_media/views.py

 from django.contrib.contenttypes.models import ContentType
 from django.core.exceptions import PermissionDenied
 from django.core.urlresolvers import get_callable
-from django.http import Http404, HttpResponse
+from django.http import Http404
 from django.views.static import serve
 from private_media.conf import settings
 
 
-def get_file(request, content_type_id=None, object_id=None, field_name=None,
-             file_name=None):
+def get_file(request, content_type_id, object_id, field_name, file_name):
     try:
         content_type = ContentType.objects.get_for_id(content_type_id)
         instance = content_type.get_object_for_this_type(**{
         })
     except Exception, e:
         raise Http404(e if settings.DEBUG else 'File not found.')
-    file = getattr(instance, field_name)
-    if not file.condition(request, instance):
+    file_field = getattr(instance, field_name)
+    if not file_field.condition(request, instance):
         raise PermissionDenied
     if settings.PRIVATE_MEDIA_INSECURE:
         response = serve(request, file_name, document_root=settings.MEDIA_ROOT)
     else:
-        handler = get_callable(file.handler, True)
+        handler = get_callable(file_field.handler, True)
         if not callable(handler):
-            raise Http404("Error importing '%s'." % file.handler
+            raise Http404("Error importing '%s'." % file_field.handler
                           if settings.DEBUG else 'File not found.')
-        response = handler(request, file)
-    if file.disposition is not None:
+        response = handler(request, file_field)
+    if file_field.disposition is not None:
         response['Content-Disposition'] = '%s; filename="%s"' % (
-            file.disposition, os.path.basename(file.name))
+            file_field.disposition, os.path.basename(file_field.name))
     return response
 
 
-def get_file_b64(request, b64_key=None, file_name=None):
+def get_file_b64(request, b64_key, file_name):
     try:
         key = urlsafe_b64decode(str(b64_key) + '==')
         content_type_id, object_id, field_name = key.split('/', 2)