Fixed image_field attributes regression
This commit is contained in:
parent
91aa90ad4a
commit
c1619d2a62
@ -1,17 +1,16 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import decimal
|
import decimal
|
||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
import time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
import warnings
|
import warnings
|
||||||
|
import itertools
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
|
|
||||||
import gridfs
|
import gridfs
|
||||||
from bson import Binary, DBRef, SON, ObjectId
|
from bson import Binary, DBRef, SON, ObjectId
|
||||||
|
|
||||||
from mongoengine.python3_support import (PY3, b, bin_type,
|
from mongoengine.python3_support import (PY3, bin_type,
|
||||||
txt_type, str_types, StringIO)
|
txt_type, str_types, StringIO)
|
||||||
from base import (BaseField, ComplexBaseField, ObjectIdField,
|
from base import (BaseField, ComplexBaseField, ObjectIdField,
|
||||||
ValidationError, get_document, BaseDocument)
|
ValidationError, get_document, BaseDocument)
|
||||||
@ -905,12 +904,12 @@ class GridFSProxy(object):
|
|||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
if isinstance(other, GridFSProxy):
|
if isinstance(other, GridFSProxy):
|
||||||
return ((self.grid_id == other.grid_id) and
|
return ((self.grid_id == other.grid_id) and
|
||||||
(self.collection_name == other.collection_name) and
|
(self.collection_name == other.collection_name) and
|
||||||
(self.db_alias == other.db_alias))
|
(self.db_alias == other.db_alias))
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def fs(self):
|
def fs(self):
|
||||||
if not self._fs:
|
if not self._fs:
|
||||||
@ -1022,7 +1021,7 @@ class FileField(BaseField):
|
|||||||
|
|
||||||
def __set__(self, instance, value):
|
def __set__(self, instance, value):
|
||||||
key = self.name
|
key = self.name
|
||||||
if ((hasattr(value, 'read') and not
|
if ((hasattr(value, 'read') and not
|
||||||
isinstance(value, GridFSProxy)) or isinstance(value, str_types)):
|
isinstance(value, GridFSProxy)) or isinstance(value, str_types)):
|
||||||
# using "FileField() = file/string" notation
|
# using "FileField() = file/string" notation
|
||||||
grid_file = instance._data.get(self.name)
|
grid_file = instance._data.get(self.name)
|
||||||
@ -1212,11 +1211,15 @@ class ImageField(FileField):
|
|||||||
params_size = ('width', 'height', 'force')
|
params_size = ('width', 'height', 'force')
|
||||||
extra_args = dict(size=size, thumbnail_size=thumbnail_size)
|
extra_args = dict(size=size, thumbnail_size=thumbnail_size)
|
||||||
for att_name, att in extra_args.items():
|
for att_name, att in extra_args.items():
|
||||||
if att and (isinstance(att, tuple) or isinstance(att, list)):
|
value = None
|
||||||
setattr(self, att_name, dict(
|
if isinstance(att, (tuple, list)):
|
||||||
zip(params_size, att)))
|
if PY3:
|
||||||
else:
|
value = dict(itertools.zip_longest(params_size, att,
|
||||||
setattr(self, att_name, None)
|
fillvalue=None))
|
||||||
|
else:
|
||||||
|
value = dict(map(None, params_size, att))
|
||||||
|
|
||||||
|
setattr(self, att_name, value)
|
||||||
|
|
||||||
super(ImageField, self).__init__(
|
super(ImageField, self).__init__(
|
||||||
collection_name=collection_name,
|
collection_name=collection_name,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user