Opened 10 years ago

Closed 8 years ago

#231 closed defect (fixed)

[patch] Make appropriate model fields honor max_length param

Reported by: nesh <nesh [at] studioquattro [dot] co [dot] yu> Owned by: donspaulding
Component: Metasystem Version:
Severity: normal Keywords: FileFields max_length sprintsept14
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Add maxlength option to FileField or another way to set maximum length. I have problem with long paths get truncated when file is posted.

Another solution is to store file names relative to upload_to parameter.

Attachments (3)

maxlength_for_filefields.diff (5.3 KB) - added by mssnlayam@… 8 years ago.
Patch
max_length_cleanups.diff (6.8 KB) - added by donspaulding 8 years ago.
For posterity.
max_length_cleanups_with_docs.diff (13.0 KB) - added by donspaulding 8 years ago.
Cleaned up handling of max_length in model fields, form fields, and added documentation. Tests included.

Download all attachments as: .zip

Change History (19)

comment:1 Changed 10 years ago by adrian

  • Summary changed from add maxlenght to FileField to Add maxlength option to FileFields

comment:2 Changed 9 years ago by donald-curtis@…

did this get closed? it really should exist, i had to manually update the table to accept the longer path names. and yes, for portability there shouldn't be full paths in my opinion.

comment:3 Changed 8 years ago by Simon G. <dev@…>

  • Keywords FileFields added
  • Triage Stage changed from Unreviewed to Accepted

Changed 8 years ago by mssnlayam@…

Patch

comment:4 Changed 8 years ago by anonymous

  • Has patch set
  • Summary changed from Add maxlength option to FileFields to [patch] Add maxlength option to FileFields

comment:5 Changed 8 years ago by mssnlayam@…

  • Patch needs improvement set

The manipulators code needs to be changed as well to support this. This patch is incomplete.

comment:6 Changed 8 years ago by donspaulding

  • Owner changed from nobody to donspaulding
  • Summary changed from [patch] Add maxlength option to FileFields to [patch] Make appropriate model fields honor max_length param
  • Triage Stage changed from Accepted to Design decision needed

I think model fields in db/models/fields/init.py need to deal with max_length in a consistent manner. They can keep their old hard-coded values if a kwarg isn't provided, but otherwise, they should use the provided one. Latest patch should reflect those changes.

comment:7 Changed 8 years ago by donspaulding

  • Needs tests set
  • Patch needs improvement unset
  • Triage Stage changed from Design decision needed to Accepted

comment:8 Changed 8 years ago by donspaulding

  • Keywords sprintsept14 added

comment:9 Changed 8 years ago by PhiR

  • Owner changed from donspaulding to PhiR
  • Status changed from new to assigned

might solve #5315.

comment:10 Changed 8 years ago by donspaulding

  • Owner changed from PhiR to donspaulding
  • Status changed from assigned to new

comment:11 Changed 8 years ago by donspaulding

  • Status changed from new to assigned

comment:12 Changed 8 years ago by donspaulding

  • Needs tests unset

comment:13 Changed 8 years ago by PhiR

  • Patch needs improvement set

The patch looks nice. I've checked that all backends are covered. One small nitpick: the doc says max_length only exist in the dev version, maybe it would be more generic to say that it is only supported in version > .96. I've had to touch tests/regressiontests/max_lengths/init.py to make the tests works though, it should be added in the patch (if possible, i know svn is tricky with empty files).

comment:14 Changed 8 years ago by donspaulding

  • Keywords max_length added
  • Patch needs improvement unset

Phir, good catch on the init file, I added a blank line so Trac's diff display would pick it up, though I'm not sure that's the standard way to add init files.

comment:15 Changed 8 years ago by donspaulding

  • Triage Stage changed from Accepted to Ready for checkin

I think this just needs a final once over by a couple of core devs before committing.

Changed 8 years ago by donspaulding

For posterity.

Changed 8 years ago by donspaulding

Cleaned up handling of max_length in model fields, form fields, and added documentation. Tests included.

comment:16 Changed 8 years ago by jacob

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

(In [6378]) Fixed #231: all fields that should take max_length now do. Thanks, Don Spaulding.

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