summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addons/caldav/caldav_node.py5
-rw-r--r--addons/caldav/orm_utils.py3
-rw-r--r--addons/document/dict_tools.py57
-rw-r--r--addons/document_webdav/dav_fs.py5
-rw-r--r--addons/document_webdav/nodes.py6
5 files changed, 71 insertions, 5 deletions
diff --git a/addons/caldav/caldav_node.py b/addons/caldav/caldav_node.py
index e1181726bbf..d91db94fc90 100644
--- a/addons/caldav/caldav_node.py
+++ b/addons/caldav/caldav_node.py
@@ -26,7 +26,10 @@ import logging
import StringIO
from orm_utils import get_last_modified
-from tools.dict_tools import dict_merge, dict_merge2
+try:
+ from tools.dict_tools import dict_merge, dict_merge2
+except ImportError:
+ from document.dict_tools import dict_merge, dict_merge2
# TODO: implement DAV-aware errors, inherit from IOError
diff --git a/addons/caldav/orm_utils.py b/addons/caldav/orm_utils.py
index badacc855c9..ab0b4bbb8db 100644
--- a/addons/caldav/orm_utils.py
+++ b/addons/caldav/orm_utils.py
@@ -41,8 +41,7 @@ if True: # we need this indentation level ;)
cr.execute('SELECT MAX(COALESCE("%s".write_date, "%s".create_date)) FROM ' % (self._table, self._table) +
from_clause + where_str ,
- where_clause_params,
- debug=self._debug)
+ where_clause_params)
res = cr.fetchall()
return res[0][0]
diff --git a/addons/document/dict_tools.py b/addons/document/dict_tools.py
new file mode 100644
index 00000000000..10d2fdc69f3
--- /dev/null
+++ b/addons/document/dict_tools.py
@@ -0,0 +1,57 @@
+# -*- encoding: utf-8 -*-
+# Copyright P. Christeas <p_christ@hol.gr> 2008-2010
+# Copyright 2010 OpenERP SA. http://www.openerp.com
+#
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public License
+# as published by the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+###############################################################################
+
+
+def dict_merge(*dicts):
+ """ Return a dict with all values of dicts
+ """
+ res = {}
+ for d in dicts:
+ res.update(d)
+ return res
+
+def dict_merge2(*dicts):
+ """ Return a dict with all values of dicts.
+ If some key appears twice and contains iterable objects, the values
+ are merged (instead of overwritten).
+ """
+ res = {}
+ for d in dicts:
+ for k in d.keys():
+ if k in res and isinstance(res[k], (list, tuple)):
+ res[k] = res[k] + d[k]
+ elif k in res and isinstance(res[k], dict):
+ res[k].update(d[k])
+ else:
+ res[k] = d[k]
+ return res
+
+def dict_filter(srcdic, keys, res=None):
+ ''' Return a copy of srcdic that has only keys set.
+ If any of keys are missing from srcdic, the result won't have them,
+ either.
+ @param res If given, result will be updated there, instead of a new dict.
+ '''
+ if res is None:
+ res = {}
+ for k in keys:
+ if k in srcdic:
+ res[k] = srcdic[k]
+ return res
+
+#eof
diff --git a/addons/document_webdav/dav_fs.py b/addons/document_webdav/dav_fs.py
index 7deb18f714c..5b5b1341679 100644
--- a/addons/document_webdav/dav_fs.py
+++ b/addons/document_webdav/dav_fs.py
@@ -37,7 +37,10 @@ import urllib
from DAV.davcmd import copyone, copytree, moveone, movetree, delone, deltree
from cache import memoize
from tools import misc
-from tools.dict_tools import dict_merge2
+try:
+ from tools.dict_tools import dict_merge2
+except ImportError:
+ from document.dict_tools import dict_merge2
CACHE_SIZE=20000
diff --git a/addons/document_webdav/nodes.py b/addons/document_webdav/nodes.py
index 67dc9fd2a4f..8bea54ab7d3 100644
--- a/addons/document_webdav/nodes.py
+++ b/addons/document_webdav/nodes.py
@@ -22,7 +22,11 @@
from document import nodes
from tools.safe_eval import safe_eval as eval
-from tools.dict_tools import dict_filter
+try:
+ from tools.dict_tools import dict_filter
+except ImportError:
+ from document.dict_tools import dict_filter
+
import urllib