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)

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

Download all attachments as: .zip

Change History (10)

comment:1 by Aymeric Augustin, 13 years ago

Component: Core (Other)Documentation
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 by Tomek Paczkowski, 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.

Last edited 13 years ago by Tomek Paczkowski (previous) (diff)

by Taavi Taijala, 13 years ago

Attachment: patch.diff added

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

comment:3 by Taavi Taijala, 13 years ago

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 by Alex Gaynor, 13 years ago

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

Renamed ticket so it's not confusing.

comment:5 by Christopher Medrela, 13 years ago

Triage Stage: AcceptedReady for checkin

comment:6 by Gabriel Hurley, 13 years ago

Component: DocumentationFile uploads/storage

comment:7 by Aymeric Augustin, 13 years ago

Needs tests: set
Triage Stage: Ready for checkinAccepted

by Aymeric Augustin, 13 years ago

Attachment: 16590.patch added

comment:8 by Aymeric Augustin, 13 years ago

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