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 #1025 (closed defect: invalid)

Opened 8 years ago

Last modified 7 years ago

Validator decorateor runs when no data is posted in controller

Reported by: Kaan Owned by: anonymous
Priority: normal Milestone: 1.0b1
Component: TurboGears Version: 0.9a6
Severity: normal Keywords:
Cc:

Description

Note: there was some disagreement on the irc channel whether or not this counts as a bug.

Here is what the decorators on a controller method look like:

@expose('tgerrs.templates.sat')
@validate(validators = {'name' : val.String(not_empty=True),
                            'number': val.Number(not_empty=True)})
@turbogears.error_handler()
@turbogears.error_handler(welcome, "tg_errors.has_key('number') and tg_errors.has_key('name')")
def index(self, tg_errors=None, **kw):
...

If I access this url without sending any data, ie just '/', it goes to the welcome page, on account of the not_empty parameters. It looks like the validators ran even though there was no data posted.

I sort of consider this counterintuitive but elvelind on irc disagreed, so I guess we'll have to decide if this is a bug or not.

Change History

comment:1 Changed 8 years ago by jorge.vargas

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

I have to aggree with elvelind on this one.

went you go to /

those 2 variable's are not created, but since there is no declaration.

the first time they are used in the validator they are initialized to "false" which ends up having the validator know they are empty and throwing the error.

they don't exits therefore are empty.

Note: See TracTickets for help on using tickets.