Thank you for the information.

I actually worked it out by explicitly calling validate function as below.
tg_errors = form.validate(**kw)

TG1 used to support validate decorator as normal decorators but in TG2 it 
is a two way process. First it hooks it up and then calls it when the 
function is actually served. 

With Regards,
Dinesh.

On Monday, 30 January 2017 00:48:59 UTC-8, Alessandro Molina wrote:
>
> It's not totally clear to me what you need to do, but @validate is not a 
> plain python decorator in TG2, it's a request hook in, so it gets processed 
> as part of request dispatch. This is so that the decorators order doesn't 
> matter, they are processed at specific request times. 
>
> @validate just registers into request flow that it should validate, but 
> it's the dispatch process that will perform the validation (independently 
> from the fact that the action is called or not) This means that manually 
> calling get_errors doesn't trigger validation as when you reach create the 
> validation phase already happened.
>
> What you are trying to do is probably just to call .validate method on the 
> form, that should run the validation for the form and give back a 
> validation error with the details of what went wrong. 
>
> On Thu, Jan 26, 2017 at 3:44 AM, D R Dinesh Kumar <[email protected] 
> <javascript:>> wrote:
>
>> Can some one help me here please?? Tried a lot of variations in 
>> validating the form but failed.
>> Any help is greatly appreciated.
>>
>>
>> On Wednesday, 25 January 2017 06:40:37 UTC-8, D R Dinesh Kumar wrote:
>>>
>>> Hi,
>>>
>>> I am migrating my TG1 project to TG2 and I have the following code in 
>>> TG1 form.
>>>
>>> def create(**kw):
>>>     form = TableForm(fields=[...], validator = [SchemaValidator1()])
>>>     
>>>     if kw:
>>>         @validate(form=form)
>>>         def get_errors(tg_errors=None, **kw):
>>>              return tg_errors, kw
>>>         tg_errors, kw = get_errors(kw)
>>>
>>> Basically, the idea was to delay the validation and do it whenever we 
>>> require (as above).
>>>
>>> How to move this code to TG2 that works?
>>> The same code in TG2 is not working and SchemaValidator1 is not being 
>>> called at all. I saw the code in TG2 for validate and found that @validate 
>>> registers the decorator and then calls them during controllerdecorators. So 
>>> how to achieve what I am looking for?
>>>
>>> Please help....
>>>
>>> With Regards,
>>> Dinesh.
>>>
>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "TurboGears" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/turbogears.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.

Reply via email to