djangotoolbox / djangotoolbox / fields.py

Diff from to

djangotoolbox/fields.py

 
 __all__ = ('GenericField', 'ListField', 'DictField', 'SetField', 'BlobField')
 
-class GenericField(models.Field):
+class RawField(models.Field):
     """ Generic field to store anything your database backend allows you to. """
-    pass
+    def get_internal_type(self):
+        return 'RawField'
 
 class AbstractIterableField(models.Field):
     """
     appropriate data type.
     """
     def __init__(self, item_field=None, *args, **kwargs):
+        if item_field is None:
+            item_field = RawField()
         self.item_field = item_field
         default = kwargs.get('default', None if kwargs.get('null') else ())
         if default is not None and not callable(default):
 
     In the latter case, the object has to provide a ``read`` method from which
     the blob is read.
-
-    If the optional keyword arguments `close_files` is ``True``, the ``close``
-    method of file-like values will be called after ``read``ing the contents
-    (if such a method exists at all).
     """
-    def __init__(self, *args, **kwargs):
-        self.close_files = kwargs.pop('close_files', False)
-        super(BlobField, self).__init__(*args, **kwargs)
-
     def get_internal_type(self):
         return 'BlobField'
 
 
     def get_db_prep_value(self, value, connection, prepared=False):
         if hasattr(value, 'read'):
-            content = value.read()
-            if self.close_files and hasattr(value, 'close'):
-                value.close()
+            return value.read()
         else:
             return str(value)
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.