Opened 17 years ago

Closed 17 years ago

#3993 closed (fixed)

[patch] Add convenience methods to SortedDict

Reported by: Paul Collier <paul@…> Owned by: nobody
Component: Core (Other) Version: dev
Severity: Keywords:
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

When generating dynamic fields for a newforms form it is convenient to have a few more SortedDict methods (particularly insert(), which is not entirely trivial) for DRY.

Attachments (1)

sorted_dict.diff (1.4 KB ) - added by Paul Collier <paul@…> 17 years ago.

Download all attachments as: .zip

Change History (7)

by Paul Collier <paul@…>, 17 years ago

Attachment: sorted_dict.diff added

comment:1 by Paul Collier <paul@…>, 17 years ago

Summary: Add convenience methods to SortedDict[patch] Add convenience methods to SortedDict

comment:2 by Chris Beaven, 17 years ago

Triage Stage: UnreviewedDesign decision needed

Seems useful, what does core think?

comment:3 by Malcolm Tredinnick, 17 years ago

Triage Stage: Design decision neededAccepted

Seems reasonable. We should check this really does implement all the useful dictionary methods and get it right -- rather than just implementing the ones Paul needs right now.

I don't think the insert() method is needed, though. SortedDict is sorted by insert order, not by anything else, so inserting out of order seems to go against the grain.

comment:4 by Paul Collier <paul@…>, 17 years ago

Hmm, okay... I was using that to dynamically insert a field at the top of a Form I was using. If it violates what's expected, don't worry about it; either I'll come up with something else or just continue to patch it solely on my installation :)

comment:5 by Fredrik Lundh <fredrik@…>, 17 years ago

Triage Stage: AcceptedReady for checkin

I think "insert" makes sense (there's already a "value_for_index" method, which breaks the "dictness" of this class). Maybe it could be called "insert_at_index"?

comment:6 by Malcolm Tredinnick, 17 years ago

Resolution: fixed
Status: newclosed

(In [6350]) Fixed #3993 -- Added some useful dictionary methods to SortedDict, plus an insert() method. Patch from Paul Collier.

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