Document translate argument of Invalid.asdict

This commit is contained in:
Alex Marandon
2013-12-21 20:55:41 +01:00
parent f6be836f74
commit d8d2681c40
3 changed files with 13 additions and 1 deletions

View File

@@ -7,6 +7,12 @@ Bug Fixes
- Un-break wrapping of callable instances as ``colander.deferred``.
See https://github.com/Pylons/colander/issues/141.
Features
~~~~~~~~
- Allow localization of error messages returned by ``colander.Invalid.asdict``
by adding an optional ``translate`` callable argument.
1.0b1 (2013-09-01)
------------------

View File

@@ -114,3 +114,4 @@ Contributors
- Brian Sutherland, 2013/08/16
- Peter Lamut, 2013/08/16
- Veeti Paananen, 2013/08/20
- Alex Marandon, 2013/12/21

View File

@@ -167,7 +167,12 @@ class Invalid(Exception):
def asdict(self, translate=None):
""" Return a dictionary containing a basic
(non-language-translated) error report for this exception"""
(non-language-translated) error report for this exception.
If ``translate`` is supplied, it must be a callable taking a
translation string as its sole argument and returning a localized,
interpolated string.
"""
paths = self.paths()
errors = {}
for path in paths: