Opened 13 years ago
Closed 13 years ago
#16590 closed Bug (fixed)
ContentFile does not have name attribute
Reported by: | Tomek Paczkowski | Owned by: | nobody |
---|---|---|---|
Component: | File uploads/storage | Version: | dev |
Severity: | Normal | Keywords: | files |
Cc: | Taavi Taijala | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
ContentFile is subclass of File and it should inherit it's interface, but name attribute is not set in constructor.
Attachments (2)
Change History (10)
comment:1 by , 13 years ago
Component: | Core (Other) → Documentation |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 13 years ago
How about empty string by default and optional init parameter? Not perfect solution, but will make ContentFile substitutable for File in more places (http://en.wikipedia.org/wiki/Liskov_substitution_principle)
I use ContentFile a lot in tests, where I don't want to touch file system if not needed. Having to check hasattr(file, 'name')
is a bit frustrating.
by , 13 years ago
Attachment: | patch.diff added |
---|
Makes ContentFile behave the same as File with regards to a name attribute
comment:3 by , 13 years ago
Cc: | added |
---|---|
Has patch: | set |
The patch I've added gives ContentFile the same keyword argument for specifying a name that File has. If no name parameter is given, then the name attribute defaults to None, as it does in File.
comment:4 by , 13 years ago
Summary: | ContentType does not have name attribute → ContentFile does not have name attribute |
---|
Renamed ticket so it's not confusing.
comment:5 by , 13 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:6 by , 13 years ago
Component: | Documentation → File uploads/storage |
---|
comment:7 by , 13 years ago
Needs tests: | set |
---|---|
Triage Stage: | Ready for checkin → Accepted |
by , 13 years ago
Attachment: | 16590.patch added |
---|
Indeed, there's an inconsistency between the code and the docs.
Since the "name" attribute doesn't really make sense for an in-memory file, I suggest fixing the docs.