spacepaste

  1.  
  2. def return_validator_error(section):
  3. def decorator(func):
  4. def wrapped(*args, **kwargs):
  5. try:
  6. return func(*args, **kwargs)
  7. except pyiv.CheckerResult as e:
  8. cherrypy.response.status=400
  9. return {
  10. "error_type":"RequestValidation",
  11. "section":section,
  12. "errors":e.error_msg(),
  13. }
  14. return wrapped
  15. return decorator
  16. @return_validator_error("ref")
  17. def api_edit(self, ref = None, values = None ):
  18. fake_delay()
  19. json = cherrypy.request.json
  20. if ref is None:
  21. ref = validator_ref( json["ref"] ).values
  22. return "actual result"
  23.