[Calypso] [PATCH] Catch and ValidateError, but still return the objects contents.

Guido Günther agx at sigxcpu.org
Mon May 16 09:29:26 PDT 2016


Hi Jelmer,
On Mon, May 16, 2016 at 04:22:42PM +0000, Jelmer Vernooij wrote:
> From: Jelmer Vernooij <jelmer at jelmer.uk>
> 
> ---
>  calypso/webdav.py | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/calypso/webdav.py b/calypso/webdav.py
> index d74ecd5..ef102fc 100644
> --- a/calypso/webdav.py
> +++ b/calypso/webdav.py
> @@ -35,6 +35,7 @@ import tempfile
>  import vobject
>  import re
>  import subprocess
> +import vobject.base
>  
>  import ConfigParser
>  
> @@ -171,7 +172,11 @@ class Item(object):
>          Text is the serialized form of the item.
>  
>          """
> -        return self.object.serialize().decode('utf-8')
> +        try:
> +            return self.object.serialize().decode('utf-8')
> +        except vobject.base.ValidateError, e:
> +            self.log.warn('Validation error %s in %s', e, self.urlpath)
> +            return self.object.serialize(validate=False).decode('utf-8')

LGTM. I thing we should switch to the python3 compatible "except Exc as
e" from now on though.
Cheers,
 -- Guido


More information about the Calypso mailing list