Opened 4 years ago

Closed 3 years ago

#16590 closed Bug (fixed)

ContentFile does not have name attribute

Reported by: oinopion Owned by: nobody
Component: File uploads/storage Version: master
Severity: Normal Keywords: files
Cc: taavi223 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 taavi223 4 years ago.
Makes ContentFile behave the same as File with regards to a name attribute
16590.patch (1.4 KB) - added by aaugustin 3 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 4 years ago by aaugustin

  • Component changed from Core (Other) to Documentation
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

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 4 years ago by oinopion

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 4 years ago by oinopion (next)

Changed 4 years ago by taavi223

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

comment:3 Changed 4 years ago by taavi223

  • Cc taavi223 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 4 years ago by Alex

  • Summary changed from ContentType does not have name attribute to ContentFile does not have name attribute

Renamed ticket so it's not confusing.

comment:5 Changed 3 years ago by krzysiumed

  • Triage Stage changed from Accepted to Ready for checkin

comment:6 Changed 3 years ago by gabrielhurley

  • Component changed from Documentation to File uploads/storage

comment:7 Changed 3 years ago by aaugustin

  • Needs tests set
  • Triage Stage changed from Ready for checkin to Accepted

Changed 3 years ago by aaugustin

comment:8 Changed 3 years ago by aaugustin

  • Resolution set to fixed
  • Status changed from new to closed

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