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 #812 (closed defect: wontfix)

Opened 13 years ago

Last modified 12 years ago

validators.to_python(kw) in controllers.py broken

Reported by: Smirnov Owned by: anonymous
Priority: normal Milestone: 0.9
Component: TurboGears Version:
Severity: major Keywords: validators formencode
Cc: simon


Looking at http://trac.turbogears.org/turbogears/changeset/1106, it seems like someone was aware that something was broken with the validation.

However, upon inspecting it further....


117 	                    try:
118 	                        value = kw.copy()
119 	                        kw.update(validators.to_python(value))

Why are we trying to validate kw? kw is list of all arguments that the method expects -- it means you end up trying to validate things like self and tg_errors, or any other parameters that are listed in the method but don't necessarily exist after you hit "Submit" on a form.

Shouldn't line 119 be instead


This isn't even hypothetical, I had trouble with formencode giving me errors, then I printed kw and I saw it was trying to validate a lot of other crap.

FORM ERRORS: The input field 'tg_errors' was not expected. <type 'str'>

Change History

comment:1 Changed 13 years ago by michele

  • Cc simon added

comment:2 Changed 13 years ago by simon

  • Component changed from CherryPy to TurboGears

We are using kw intentionally, allowing one to pass state between decorators and consequently figure this state in validation, if so desired.

Also note code above gets executed only if a singular validator or scheme is being passed to validate. Also, schemas derivering from turbogears.validators.Schema have attribute allow_extra_fields set to True, avoiding potential problems with overabundance of arguments.

comment:3 Changed 13 years ago by Smirnov

Good to know what's going on. I checked the newsgroups and a few changelogs and I couldn't find anything. I suggest updating the 0.9 documentation to tell users to inherit from turbogears.validators.Schema rather than formencode.validators.schema so people don't have to go through stack trace after stack trace while crying ;).

I changed the parent class and everything is working like in 0.8 now. Feel free to close this whenever you guys figure out how to inform past 0.8 users (perhaps add an extra message next to the existing 'default value' blurb at  http://www.turbogears.org/preview/download/upgrade.html).

comment:4 Changed 13 years ago by simon

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

We are working hard on getting documentation for 0.9/1.0 up to scratch (we freely admit right now it's in a sorry state of affairs).

Glad to see everything worked out for you!

comment:5 Changed 13 years ago by Smirnov

Great simon, thanks a lot.. I hope if other people have this problem they find this ticket too!

Note: See TracTickets for help on using tickets.