Thank you Simon

I tested the proposed parameter order and names. Unfortunatly it
doesn't work.
I get this trace:

File
"/usr/lib/python2.4/site-packages/TurboGears-0.9a6-py2.4.egg/turbogears/errorhandling.py",
line 97, in run_with_errors
    return self.validation_error(func.__name__, kw, errors)
TypeError: validation_error() takes exactly 3 arguments (4 given)

It seems that the number of parameters is wrong.
I am investigating the errorhandling.py code, but I am far to be a
Python expert and I have difficulties to understand how it works.  Any
other clue is welcome ;-)
Thanks again
Arnold


Simon Belak wrote:
> tg_errors should contain field name and error pairs while unmolested
> input is in kw.
>
> Try:
>
>       def validation_error(self, tg_errors,tg_source, **kw):
>
>
> may be of help as well:
> http://trac.turbogears.org/turbogears/wiki/HowDoesErrorHandlingWork
>
> Cheers,
> Simon
>
> Arnold wrote:
> > Simon,
> >
> > Looking at the TG code, I came to the conclusion that the order of
> > parametres should be  like that:
> > validation_error(tg_errors,tg_source,self,kw):
> >
> > My test code is :
> >
> > def validation_error(tg_errors,tg_source,self,kw):
> >             appliLogger.debug("Validator_error tg_source : "+ tg_source)
> >             appliLogger.debug("Validator_error kw : "+ str(kw))
> >             appliLogger.debug("Validator_error tg_errors : "+ 
> > str(tg_errors))
> >             errorList=kw.keys()
> >
> > The log is this one:
> > 2006-07-02 21:47:24,165 DEBUG Validator_error tg_source : suscribe
> > 2006-07-02 21:47:24,166 DEBUG Validator_error kw : {'age':
> > <formencode.api.Invalid instance at 0xb09ef38c>}
> > 2006-07-02 21:47:24,166 DEBUG Validator_error tg_errors :
> > <newgears.controllers.Root object at 0xb7450aec>
> >
> > tg_source: it's ok, I get a string with the name of the calling
> > function
> > kw: it's OK, I get a dictionnary with the names of the parameters that
> > failed in validation
> > tg_errors: I thought that it would contain the parameters initially
> > sentby the browser to the calling function, but it doens't. I don't
> > understand what it is.
> > Can you explain ?
> > Thanks
> > Arnold
> >
> > Simon Belak wrote:
> >> **kw needs to be last (a Python limitation, see keyword arguements).
> >>
> >> Cheers,
> >> Simon
> >>
> >> Arnold wrote:
> >>> Thank you Simon,
> >>>
> >>> I replaced the names like this : def validation_error(self, tg_source,
> >>> **kw, tg_errors):
> >>> The fundamental change is **kw instead of kw, but I get an error at
> >>> server launch:
> >>>
> >>> def validation_error(self, tg_source, **kw, tg_errors):
> >>>                                                                ^
> >>> SyntaxError: invalid syntax
> >>>
> >>> I believe that  tg_source, **kw, tg_errors are names in calling
> >>> program.
> >>> Have you a short code example ?
> >>> Thanks again
> >>> Arnold
> >>>
> >>>
> >>> Simon Belak wrote:
> >>>> Arnold wrote:
> >>>>> I can't get the form parameters that go through the validator. My code:
> >>>>>
> >>>>>         @turbogears.expose(html="newgears.templates.confirmation")
> >>>>>         @turbogears.validate(validators={ "mailAdress" : 
> >>>>> validators.Email()})
> >>>>>
> >>>>> ...
> >>>>>
> >>>>> def validation_error(self, funcname, kw, errors):
> >>>>>
> >>>>> When the email is invalid, validation_error is correctly called but kw
> >>>>> is empty : {}
> >>>>>
> >>>>> I guess my code is wrong ! Any clue appreciated
> >>>>> Arnold
> >>>> If the above is actual code, you have your argument names wrong. Try
> >>>>
> >>>> funcname -> tg_source
> >>>> errors -> tg_errors
> >>>> kw -> **kw
> >>>>
> >>>> Cheers,
> >>>> Simon
> >>>
> > 
> > 
> > > 
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to