Opened 2 years ago

Closed 16 months 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 2 years ago.

Download all attachments as: .zip

Change History (6)

Changed 2 years ago by etox

comment:1 Changed 2 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 19 months ago by vijay_shanker

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

comment:3 Changed 19 months ago by anonymous

  • Owner changed from vijay_shanker to anonymous

comment:4 Changed 16 months ago by aaugustin

  • Type changed from Uncategorized to Cleanup/optimization

comment:5 Changed 16 months ago by aaugustin

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

No one addressed Alex' point on backwards compatibility.

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.