Opened 19 years ago
Closed 18 years ago
#3993 closed (fixed)
[patch] Add convenience methods to SortedDict
| Reported by: | 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)
Change History (7)
by , 19 years ago
| Attachment: | sorted_dict.diff added | 
|---|
comment:1 by , 19 years ago
| Summary: | Add convenience methods to SortedDict → [patch] Add convenience methods to SortedDict | 
|---|
comment:2 by , 19 years ago
| Triage Stage: | Unreviewed → Design decision needed | 
|---|
comment:3 by , 19 years ago
| Triage Stage: | Design decision needed → Accepted | 
|---|
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 , 19 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 , 18 years ago
| Triage Stage: | Accepted → Ready 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 , 18 years ago
| Resolution: | → fixed | 
|---|---|
| Status: | new → closed | 
(In [6350]) Fixed #3993 -- Added some useful dictionary methods to SortedDict, plus an insert() method. Patch from Paul Collier.
Seems useful, what does core think?