Reviewers: ,
Please review this at http://codereview.tryton.org/163015/
Affected files:
M trytond/protocols/webdav.py
M trytond/webdav/webdav.py
Index: trytond/protocols/webdav.py
===================================================================
--- a/trytond/protocols/webdav.py
+++ b/trytond/protocols/webdav.py
@@ -11,11 +11,20 @@
import logging
from threading import local
import xml.dom.minidom
-from DAV import AuthServer, WebDAVServer, iface
-from DAV.errors import *
-from DAV.constants import COLLECTION, DAV_VERSION_1, DAV_VERSION_2
-from DAV.utils import get_uriparentpath, get_urifilename, quote_uri
-from DAV.davcmd import copyone, copytree, moveone, movetree, delone,
deltree
+try:
+ from DAV import AuthServer, WebDAVServer, iface
+ from DAV.errors import *
+ from DAV.constants import COLLECTION, DAV_VERSION_1, DAV_VERSION_2
+ from DAV.utils import get_uriparentpath, get_urifilename, quote_uri
+ from DAV.davcmd import copyone, copytree, moveone, movetree, delone,
deltree
+except ImportError:
+ from pywebdav.lib import AuthServer, WebDAVServer, iface
+ from pywebdav.lib.errors import *
+ from pywebdav.lib.constants import COLLECTION, DAV_VERSION_1,
DAV_VERSION_2
+ from pywebdav.lib.utils import get_uriparentpath, get_urifilename, \
+ quote_uri
+ from pywebdav.lib.davcmd import copyone, copytree, moveone, movetree, \
+ delone, deltree
from trytond.protocols.sslsocket import SSLSocket
from trytond.protocols.common import daemon
from trytond.config import CONFIG
@@ -47,7 +56,10 @@
CACHE = LocalDict()
# Fix for bad use of Document in DAV.utils make_xmlresponse
-from DAV.utils import VERSION as DAV_VERSION
+try:
+ from DAV.utils import VERSION as DAV_VERSION
+except ImportError:
+ from pywebdav.lib import VERSION as DAV_VERSION
if DAV_VERSION == '0.6':
from xml.dom.Document import Document
Document.Document = Document
Index: trytond/webdav/webdav.py
===================================================================
--- a/trytond/webdav/webdav.py
+++ b/trytond/webdav/webdav.py
@@ -306,7 +306,10 @@
return res
def get_resourcetype(self, uri, cache=None):
- from DAV.constants import COLLECTION, OBJECT
+ try:
+ from DAV.constants import COLLECTION, OBJECT
+ except ImportError:
+ from pywebdav.lib.constants import COLLECTION, OBJECT
object_name, object_id = self._uri2object(uri, cache=cache)
if object_name in ('ir.attachment', 'ir.action.report'):
return OBJECT
@@ -434,7 +437,10 @@
return time.time()
def get_data(self, uri, cache=None):
- from DAV.errors import DAV_NotFound
+ try:
+ from DAV.errors import DAV_NotFound
+ except ImportError:
+ from pywebdav.lib.errors import DAV_NotFound
pool = Pool()
attachment_obj = pool.get('ir.attachment')
report_obj = pool.get('ir.action.report')
@@ -487,8 +493,12 @@
raise DAV_NotFound
def put(self, uri, data, content_type, cache=None):
- from DAV.errors import DAV_Forbidden
- from DAV.utils import get_uriparentpath, get_urifilename
+ try:
+ from DAV.errors import DAV_Forbidden
+ from DAV.utils import get_uriparentpath, get_urifilename
+ except ImportError:
+ from pywebdav.lib.errors import DAV_Forbidden
+ from pywebdav.lib.utils import get_uriparentpath,
get_urifilename
object_name, object_id = self._uri2object(get_uriparentpath(uri),
cache=cache)
if not object_name \
@@ -519,8 +529,12 @@
return
def mkcol(self, uri, cache=None):
- from DAV.errors import DAV_Forbidden
- from DAV.utils import get_uriparentpath, get_urifilename
+ try:
+ from DAV.errors import DAV_Forbidden
+ from DAV.utils import get_uriparentpath, get_urifilename
+ except ImportError:
+ from pywebdav.lib.errors import DAV_Forbidden
+ from pywebdav.lib.utils import get_uriparentpath,
get_urifilename
if uri[-1:] == '/':
uri = uri[:-1]
object_name, object_id = self._uri2object(get_uriparentpath(uri),
@@ -538,7 +552,10 @@
return 201
def rmcol(self, uri, cache=None):
- from DAV.errors import DAV_Forbidden
+ try:
+ from DAV.errors import DAV_Forbidden
+ except ImportError:
+ from pywebdav.errors import DAV_Forbidden
object_name, object_id = self._uri2object(uri, cache=cache)
if object_name != 'webdav.collection' \
or not object_id:
@@ -550,7 +567,10 @@
return 200
def rm(self, uri, cache=None):
- from DAV.errors import DAV_Forbidden
+ try:
+ from DAV.errors import DAV_Forbidden
+ except ImportError:
+ from pywebdav.errors import DAV_Forbidden
object_name, object_id = self._uri2object(uri, cache=cache)
if not object_name:
raise DAV_Forbidden
--
tryton-dev@googlegroups.com mailing list