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
-~----------~----~----~----~------~----~------~--~---