Opened 17 years ago

Closed 16 years ago

#4321 closed (wontfix)

BoundField.as_hidden() assumes hidden_widget is a class

Reported by: Chris Beaven Owned by: nobody
Component: Forms Version: dev
Severity: Keywords: newforms
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The hidden_widget of a field could just as easily be (and is, in a case I'm using) a Widget instance rather than a Widget class but BoundField.as_hidden() assumes that it is always a class.

Simple patch attached checks first before trying to instantiate the hidden_widget.

Attachments (1)

hidden_widget.patch (961 bytes ) - added by Chris Beaven 17 years ago.

Download all attachments as: .zip

Change History (4)

by Chris Beaven, 17 years ago

Attachment: hidden_widget.patch added

comment:1 by Adrian Holovaty, 17 years ago

What's the use case for hidden_widget being an instance rather than a class?

comment:2 by Adrian Holovaty, 17 years ago

Triage Stage: UnreviewedDesign decision needed

comment:3 by Luke Plant, 16 years ago

Resolution: wontfix
Status: newclosed

isinstance bad, duck typing good: this patch would break if hidden_widget:

  • was a class but not a subclass of Widget
  • was some other callable that returned a widget e.g. a function that wraps a Widget constructor

In fact, thinking of the latter, you can work around this perfectly if you set hidden_widget = lambda: my_widget_instance, AFAICS

So, seeing it is currently flexible enough to cope, and adding this would make it much less flexible, I'm closing WONTFIX, please reopen if I missed something.

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