Document, caldav: inhibit features not found on trunk server.

bzr revid: p_christ@hol.gr-20101012112733-sqcnvobi5q8ztj3l
This commit is contained in:
P. Christeas
2010-10-12 14:27:33 +03:00
parent 305b48abe3
commit 60f2488feb
5 changed files with 71 additions and 5 deletions
+4 -1
View File
@@ -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
+1 -2
View File
@@ -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]
+57
View File
@@ -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
+4 -1
View File
@@ -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
+5 -1
View File
@@ -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