Changes between Version 2 and Version 3 of FileStorageRefactor
- Timestamp:
- Aug 5, 2008, 10:13:47 PM (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
FileStorageRefactor
v2 v3 6 6 7 7 * `FileField` now provides a `FieldFile` object instead just a filename, so that file operations can take place on it directly. This was needed on one hand to move people away from the `open(instance.get_avatar_filename())`, since that won't work once other backends enter the picture. Instead, `instance.avatar` can be used as a file-like object directly. Also, it has `path`, `size` and `url` properties instead of `get_foo_*`. 8 9 * Since there's bound to be a lot of code in the wild that uses `open()`, I tried my hand at an easier path toward backwards-compatibility for those folks, by supplying `django.core.files.open`. It works just same as the builtin, but uses `FileSystemStorage` behind the scenes, so the object it returns is a `django.core.files.File`, with all of its bells and whistles available. '''NOTE''': Since this is a replacement for the builtin `open()`, it does ''not'' obey the `DEFAULT_FILE_STORAGE` setting. It just uses `FileSystemStorage` directly, all the time.10 8 11 9 * The `open()` method of storage objects also accepts a `mixin` argument, which allows the returned `File` to have overrides and extra methods for specific file types.