Opened 4 years ago

Closed 3 years ago

#17650 closed Cleanup/optimization (wontfix)

BaseForm doesn't implement __contains__

Reported by: etox 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


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 etox 4 years ago.

Download all attachments as: .zip

Change History (6)

Changed 4 years ago by etox

comment:1 Changed 4 years ago by Alex

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design 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 Changed 3 years ago by vijay_shanker

  • Owner changed from nobody to vijay_shanker
  • Status changed from new to assigned

comment:3 Changed 3 years ago by anonymous

  • Owner changed from vijay_shanker to anonymous

comment:4 Changed 3 years ago by aaugustin

  • Type changed from Uncategorized to Cleanup/optimization

comment:5 Changed 3 years ago by aaugustin

  • Resolution set to wontfix
  • Status changed from assigned to closed

No one addressed Alex' point on backwards compatibility.

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