Beispiel #1
0
    def dehydrate(self, bundle):
        """
        :param bundle:
        :return:
        """

        # Deep copy the structure to create new dict instance so we don't mutilate the source
        try:
            if not isinstance(getattr(bundle.obj, self.attribute), dict):
                return {}
            value = super(PickledDictField, self).dehydrate(bundle)
            return my_deep_copy(value)
        except:
            setattr(bundle.obj, self.attribute, None) # value got deformed--clear it
            return my_deep_copy(super(PickledDictField, self).dehydrate(bundle))
Beispiel #2
0
    def dehydrate(self, bundle):
        """
            Handles the object dehydration
        :param bundle:
        :return:
        """

        # Deep copy the structure to create new dict instance so we don't mutilate the source
        obj = super(PickledObjField, self).dehydrate(bundle)
        return my_deep_copy(obj, True)
Beispiel #3
0
    def convert(self, value):
        if value is None:
            return None

        return my_deep_copy(value, True)
 def remove_auto(field):
     modified_field = my_deep_copy(field)
     modified_field.auto_created = False
     modified_field.primary_key = False
     return modified_field