Opened 19 years ago

Closed 17 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: no UI/UX: no

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@… 17 years ago.
Patch
max_length_cleanups.diff (6.8 KB ) - added by donspaulding 17 years ago.
For posterity.
max_length_cleanups_with_docs.diff (13.0 KB ) - added by donspaulding 17 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 by Adrian Holovaty, 19 years ago

Summary: add maxlenght to FileFieldAdd maxlength option to FileFields

comment:2 by donald-curtis@…, 18 years ago

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 by Simon G. <dev@…>, 17 years ago

Keywords: FileFields added
Triage Stage: UnreviewedAccepted

by mssnlayam@…, 17 years ago

Patch

comment:4 by anonymous, 17 years ago

Has patch: set
Summary: Add maxlength option to FileFields[patch] Add maxlength option to FileFields

comment:5 by mssnlayam@…, 17 years ago

Patch needs improvement: set

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

comment:6 by donspaulding, 17 years ago

Owner: changed from nobody to donspaulding
Summary: [patch] Add maxlength option to FileFields[patch] Make appropriate model fields honor max_length param
Triage Stage: AcceptedDesign 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 by donspaulding, 17 years ago

Needs tests: set
Patch needs improvement: unset
Triage Stage: Design decision neededAccepted

comment:8 by donspaulding, 17 years ago

Keywords: sprintsept14 added

comment:9 by Philippe Raoult, 17 years ago

Owner: changed from donspaulding to Philippe Raoult
Status: newassigned

might solve #5315.

comment:10 by donspaulding, 17 years ago

Owner: changed from Philippe Raoult to donspaulding
Status: assignednew

comment:11 by donspaulding, 17 years ago

Status: newassigned

comment:12 by donspaulding, 17 years ago

Needs tests: unset

comment:13 by Philippe Raoult, 17 years ago

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 by donspaulding, 17 years ago

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 by donspaulding, 17 years ago

Triage Stage: AcceptedReady for checkin

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

by donspaulding, 17 years ago

Attachment: max_length_cleanups.diff added

For posterity.

by donspaulding, 17 years ago

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

comment:16 by Jacob, 17 years ago

Resolution: fixed
Status: assignedclosed

(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