Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixing SizedImageField to work properly under WSGI

  • Loading branch information...
commit 96046074bd9427a4edda2fa27430ea918b4e7f96 1 parent a3ad1dd
@andrewhayward andrewhayward authored
Showing with 6 additions and 4 deletions.
  1. +6 −4 make_mozilla/core/fields.py
View
10 make_mozilla/core/fields.py
@@ -3,12 +3,14 @@
from django.db import models
from django.db.models.fields import files
from PIL import Image
-from os.path import abspath
+from os import path
import cStringIO
+import make_mozilla
from south.modelsinspector import add_introspection_rules
add_introspection_rules([], ['^make_mozilla\.core\.fields\.SizedImageField'])
+ROOT = path.dirname(path.dirname(make_mozilla.__file__))
class SizedImageFieldFile(files.ImageFieldFile):
@@ -26,9 +28,9 @@ def __init__(self, *args, **kwargs):
try:
original_width, original_height = (self.width, self.height)
- except SuspiciousOperation as e:
+ except SuspiciousOperation:
try:
- original_width, original_height = Image.open(abspath(self.name[1:])).size
+ original_width, original_height = Image.open('%s%s' % (ROOT, self.name)).size
except IOError:
original_width = original_height = False
@@ -81,7 +83,7 @@ def get_width_height(self, size):
except IOError:
height = None
except SuspiciousOperation:
- ow, oh = Image.open(abspath(self.name[1:])).size
+ ow, oh = Image.open('%s%s' % (ROOT, self.name)).size
height = width / float(ow) * oh
except TypeError:
width = size[0]
Please sign in to comment.
Something went wrong with that request. Please try again.