From fb7bddf5cf2e25be3e48a83e8ca30fbee38365d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 10 Nov 2009 14:03:20 +0100 Subject: [PATCH] Improve exception handling for issue1180 --- trytond/protocols/webdav.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/trytond/protocols/webdav.py b/trytond/protocols/webdav.py index 8db6e5e01d..bd826be0f8 100644 --- a/trytond/protocols/webdav.py +++ b/trytond/protocols/webdav.py @@ -194,6 +194,8 @@ class TrytonDAVInterface(iface.dav_interface): for child in collection_obj.get_childs(cursor, int(USER_ID), dburi, filter=filter, cache=CACHE): res.append(uri + child.encode('utf-8')) + except KeyError: + return res except (DAV_Error, DAV_NotFound, DAV_Secret, DAV_Forbidden), exception: self._log_exception(exception) raise @@ -389,7 +391,7 @@ class TrytonDAVInterface(iface.dav_interface): def rmcol(self, uri): dbname, dburi = self._get_dburi(uri) if not dbname or not dburi: - raise DAV_Forbidden + return 403 cursor = DATABASE['cursor'] pool = Pool(DATABASE['dbname']) collection_obj = pool.get('webdav.collection') @@ -397,20 +399,16 @@ class TrytonDAVInterface(iface.dav_interface): res = collection_obj.rmcol(cursor, int(USER_ID), dburi, cache=CACHE) cursor.commit() - except (DAV_Error, DAV_NotFound, DAV_Secret, DAV_Forbidden), exception: - self._log_exception(exception) - cursor.rollback() - raise except Exception, exception: self._log_exception(exception) cursor.rollback() - raise DAV_Error(500) + return 500 return res def rm(self, uri): dbname, dburi = self._get_dburi(uri) if not dbname or not dburi: - raise DAV_Forbidden + return 403 cursor = DATABASE['cursor'] pool = Pool(DATABASE['dbname']) collection_obj = pool.get('webdav.collection') @@ -418,14 +416,10 @@ class TrytonDAVInterface(iface.dav_interface): res = collection_obj.rm(cursor, int(USER_ID), dburi, cache=CACHE) cursor.commit() - except (DAV_Error, DAV_NotFound, DAV_Secret, DAV_Forbidden), exception: - self._log_exception(exception) - cursor.rollback() - raise except Exception, exception: self._log_exception(exception) cursor.rollback() - raise DAV_Error(500) + return 500 return res def exists(self, uri):