Opened 5 years ago

Closed 5 years ago

#16590 closed Bug (fixed)

ContentFile does not have name attribute

Reported by: Tomek Paczkowski Owned by: nobody
Component: File uploads/storage Version: master
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)

patch.diff (619 bytes) - added by Taavi Taijala 5 years ago.
Makes ContentFile behave the same as File with regards to a name attribute
16590.patch (1.4 KB) - added by Aymeric Augustin 5 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 5 years ago by Aymeric Augustin

Component: Core (Other)Documentation
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

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.

comment:2 Changed 5 years ago by Tomek Paczkowski

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.

Version 0, edited 5 years ago by Tomek Paczkowski (next)

Changed 5 years ago by Taavi Taijala

Attachment: patch.diff added

Makes ContentFile behave the same as File with regards to a name attribute

comment:3 Changed 5 years ago by Taavi Taijala

Cc: Taavi Taijala 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 Changed 5 years ago by Alex Gaynor

Summary: ContentType does not have name attributeContentFile does not have name attribute

Renamed ticket so it's not confusing.

comment:5 Changed 5 years ago by Christopher Medrela

Triage Stage: AcceptedReady for checkin

comment:6 Changed 5 years ago by Gabriel Hurley

Component: DocumentationFile uploads/storage

comment:7 Changed 5 years ago by Aymeric Augustin

Needs tests: set
Triage Stage: Ready for checkinAccepted

Changed 5 years ago by Aymeric Augustin

Attachment: 16590.patch added

comment:8 Changed 5 years ago by Aymeric Augustin

Resolution: fixed
Status: newclosed

In [17298]:

Fixed #16590 -- Accepted a 'name' argument in the constructor of ContentFile, for consistency with File.

Note: See TracTickets for help on using tickets.
Back to Top