Opened 13 years ago

Closed 12 years ago

#17650 closed Cleanup/optimization (wontfix)

BaseForm doesn't implement __contains__

Reported by: Jaime Irurzun Owned by: anonymous
Component: Forms Version: 1.4-alpha-1
Severity: Normal Keywords:
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

BaseForm currently implements iter and getitem, wrapping access to self.fields. It would be nice if it also implemented contains, so you could check for a name being a field of a form object.

Attachments (1)

baseform_contains.diff (1.3 KB ) - added by Jaime Irurzun 13 years ago.

Download all attachments as: .zip

Change History (6)

by Jaime Irurzun, 13 years ago

Attachment: baseform_contains.diff added

comment:1 by Alex Gaynor, 13 years ago

Triage Stage: UnreviewedDesign decision needed

Ugh, I'm actually concerned about this, because it breaks existing code. Currently field_instance in form works, because if __contains__ isn't defined the in operator falls back to iterating over this, which iterates over the values of fields, rather than the keys in that dict. This behavior is different from all other mapping containers, so this requires a lot more though IMO.

comment:2 by vijay_shanker, 12 years ago

Owner: changed from nobody to vijay_shanker
Status: newassigned

comment:3 by anonymous, 12 years ago

Owner: changed from vijay_shanker to anonymous

comment:4 by Aymeric Augustin, 12 years ago

Type: UncategorizedCleanup/optimization

comment:5 by Aymeric Augustin, 12 years ago

Resolution: wontfix
Status: assignedclosed

No one addressed Alex' point on backwards compatibility.

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