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 #1273 (closed defect: duplicate)

Opened 12 years ago

Last modified 11 years ago

SingleSelectField in a form should use validator from schema

Reported by: Chris Arndt Owned by: alberto
Priority: normal Milestone: 1.5
Component: ToscaWidgets Version: 1.0.1
Severity: normal Keywords: widget, form, singleselect, validation


As explained in this thread:


and demonstrated in this code:


when using a SingleSelectField in a form widget with a validation schema, the validator for the SingleSelectField in the validation schema is not taken into account and the form declaration fails with

ValueError: No validator specified and couldn't guess one. I cannot work
properly without it

when the options argument to the SingleSelectField constructor is empty and the validator can not be guessed.

Adding a validator to the SingleSelectField constructor works around the problem but goes against the DRY principle. Arguably the whole validator guessing behaviour of SingleSelectFields causes more problems than it solves. See the references to previous posts about this bug later in the same thread:


IMO, it should be recognised that there is a validator for the SingleSelectField in the schema. If there is none, an exception should be thrown when the form is instantiated.

Change History

comment:1 Changed 12 years ago by Chris Arndt

  • Keywords singleselect, added; singelselect, removed
  • Version changed from 1.0 to 1.0.1

comment:2 Changed 12 years ago by shday

Guessing the validator here is kind of unpythonic IMO. A new user won't know why validation is happening when no validator is explicitly declared.

comment:3 Changed 12 years ago by alberto

  • Owner changed from anonymous to alberto
  • Component changed from Widgets to toscaWidgets
  • Milestone changed from 1.0.2 to 1.1

Removing the guessing behaviour in 1.0 will break some apps which depend on it so its not doable. Picking up the validator from the Schema is not possible given the current design because the SingleSelectField? is instantiated before the Schema is (so it will barf that ValueError? anyway) and making the form assign it one when the schema is built is not possible either because compound widgets should not modify their children because they might be shared among other compound widgets.

However, this is solvable in ToscaWidgets? because child widgets can be cloned by their parent to initialize them with different parameters.

I'll move this ticket to ToscaWidgets? to remind me (or someone) to implement it sometime.


comment:4 Changed 11 years ago by alberto

  • Status changed from new to closed
  • Resolution set to duplicate
Note: See TracTickets for help on using tickets.