--
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 turbogears+...@googlegroups.com.
To post to this group, send email to turbo...@googlegroups.com.
Visit this group at http://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.
I fix the classes I gave as example:
# The validation model
WikiPageValidator(object):# Here is a controller method (or function)
todict(self):
return {
"title": validators.UnicodeString,
"content": validators.UnicodeString,
}
from formencode import validators
@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))
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 ?
Far from being perfect but I use https://pypi.python.org/pypi/sphinxcontrib-jsoncall which autogenerates doc for all json controllers. Just remember to skip /admin
--
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 turbogears+unsubscribe@googlegroups.com.