Changes between Initial Version and Version 1 of Ticket #11027, comment 17
- Timestamp:
- Sep 30, 2012, 7:13:59 PM (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #11027, comment 17
initial v1 3 3 get_available_name needs to take a max_length argument, or it needs to be able to guarantee that it won't increase the length of the filename. Since the latter isn't possible as far as I can see, I expect to do the former. If get_available_name *can't* make a name within the given max length, it will raise a !ValueError. !FileField validation would then need to call get_available_name *after* generating a filename and instead of (or after) a simple check of the length of the filename. Any !ValueError raised can be re-raised as a !ValidationError. 4 4 5 As an alternative, we could add a new storage method called (say) get_valid_storage_path, which would handle max_length and the available_name checks, then deprecate get_available_name.5 Since get_available_name is part of the public API, this would mean either doing introspection, wrapping every call to get_available_name in try/except, or adding a new method called (say) get_valid_storage_path, which would handle max_length and the available_name checks, then deprecate get_available_name. Personally, I would lean toward the latter option, since I find the whole name/filename/path/storage path naming mess confusing.