Opened 12 years ago

Closed 12 years ago

#3993 closed (fixed)

[patch] Add convenience methods to SortedDict

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


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@…> 12 years ago.

Download all attachments as: .zip

Change History (7)

Changed 12 years ago by Paul Collier <paul@…>

Attachment: sorted_dict.diff added

comment:1 Changed 12 years ago by Paul Collier <paul@…>

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

comment:2 Changed 12 years ago by Chris Beaven

Triage Stage: UnreviewedDesign decision needed

Seems useful, what does core think?

comment:3 Changed 12 years ago by Malcolm Tredinnick

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 Changed 12 years ago by Paul Collier <paul@…>

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 Changed 12 years ago by Fredrik Lundh <fredrik@…>

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 Changed 12 years ago by Malcolm Tredinnick

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