Removed subfieldbase and use from_db_value as recommended by django deprecation info.

This commit is contained in:
Griatch 2016-02-19 22:58:52 +01:00
parent 43dc48a675
commit d6c649f551

View file

@ -116,18 +116,6 @@ def dbsafe_decode(value, compress_object=False):
value = decompress(value)
return loads(value)
#def _get_subfield_superclass():
# # hardcore trick to support django < 1.3 - there was something wrong with
# # inheritance and SubfieldBase before django 1.3
# # see https://github.com/django/django/commit/222c73261650201f5ce99e8dd4b1ce0d30a69eb4
# if django.VERSION < (1,3):
# return models.Field
# # mimic six.with_metaclass
# meta = models.SubfieldBase
# base = models.Field
# return meta("NewBase", (base,), {})
# #return six.with_metaclass(models.SubfieldBase, models.Field)
class PickledWidget(Textarea):
def render(self, name, value, attrs=None):
@ -168,7 +156,7 @@ class PickledFormField(CharField):
raise ValidationError(self.error_messages['invalid'])
class PickledObjectField(with_metaclass(models.SubfieldBase, models.Field)):
class PickledObjectField(models.Field):
"""
A field that will accept *any* python object and store it in the
database. PickledObjectField will optionally compress its values if
@ -203,9 +191,8 @@ class PickledObjectField(with_metaclass(models.SubfieldBase, models.Field)):
# If the field doesn't have a default, then we punt to models.Field.
return super(PickledObjectField, self).get_default()
#def from_db_value():pass
def to_python(self, value):
#def to_python(self, value):
def from_db_value(self, value, *args):
"""
B64decode and unpickle the object, optionally decompressing it.