On Mon, Mar 31, 2014 at 11:28 AM, <[email protected]> wrote:
> I fix the classes I gave as example:
>
> # The validation model
> WikiPageValidator(object):
> todict(self):
> return {
> "title": validators.UnicodeString,
> "content": validators.UnicodeString,
> }
>
> from formencode import validators
>
> # Here is a controller method (or function)
> @expose('json')
> @validate(validators=WikiPageValidator.todict())
> def post(self, title=None, content=None, *args):
> errors = [{key, value} in pylons.c.form_errors.iteritems()]
> values = pylons.c.form_values
> return dict(a=a, b=b, errors=str(errors), values=str(values))
>
>
Why not just inherit from a formencode.Schema? It would do the same thing
without the need to call todict().
It's actually meant for that.
> What would be wonderfull would be to define controllers with given
> Validator as controller parameters, eg:
>
> # Here is a controller method (or function)
> @expose('json')
> @validate(validators=WikiPage)
> def post(self, workload = WikiPage()):
> ...
> ...
> return dict(workload = workload)
>
> Do you think it's easy to implement? Maybe there is already something that
> would act similarly to this ? Maybe a decorator that would map every
> attribute to the same class member of the given model ?
>
I didn't understand :D
Can you explain it again?
--
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 http://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.