Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #299 (closed defect: fixed)

Opened 14 years ago

Last modified 12 years ago

Misleading signature for SelectField widget

Reported by: matt@… Owned by: anonymous
Priority: normal Milestone: 0.9
Component: TG Widgets Version: 0.8
Severity: normal Keywords:
Cc:

Description

Widget.__init__() asks for a dictionary for the options keyword (options = {}), although of course with Python's duck-typing, any type can be passed. Unfortunately, as of r348 SelectField? expects options to be a list of tuples. This causes hard-to-parse errors when SelectField? is passed a dictionary for the options.

The two solutions are to change the various OptionsWidget?-derived functions to take a dictionary, or to set options = [] in Widget's init() method as a guide for the developer. I prefer the former (Explicit>Implicit, and dicts are more explicit than tuples), but it will break existing code.

Change History

comment:1 Changed 14 years ago by KarlGuertin

SelectField? probably takes a list of tuples because order matters in a select.

comment:2 Changed 14 years ago by matt@…

  • Status changed from new to closed
  • Resolution set to fixed

Of course, thanks for pointing that out. Here's hoping an ordered dict makes it into the standard library someday.

This has been fixed by the patch submitted in {304}.

Note: See TracTickets for help on using tickets.