diff --git a/CHANGELOG b/CHANGELOG index 2bc7e0793b..26124b24ec 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Handle displayname on webdav.collection * Handle current-user-privilege-set on webdav.collection Version 1.4.0 - 2009-10-19 diff --git a/trytond/protocols/webdav.py b/trytond/protocols/webdav.py index 9a6b7a79f7..ce6cd25483 100644 --- a/trytond/protocols/webdav.py +++ b/trytond/protocols/webdav.py @@ -316,7 +316,24 @@ class TrytonDAVInterface(iface.dav_interface): return res def _get_dav_displayname(self, uri): - return uri.split('/')[-1] + dbname, dburi = self._get_dburi(uri) + if not dbname or not dburi: + return uri.split('/')[-1] + cursor = DATABASE['cursor'] + pool = Pool(DATABASE['dbname']) + try: + collection_obj = pool.get('webdav.collection') + res = collection_obj.get_displayname(cursor, int(USER_ID), dburi, + cache=CACHE) + except KeyError: + raise DAV_NotFound + except (DAV_Error, DAV_NotFound, DAV_Secret, DAV_Forbidden), exception: + self._log_exception(exception) + raise + except Exception, exception: + self._log_exception(exception) + raise DAV_Error(500) + return res def _get_dav_getcontentlength(self, uri): dbname, dburi = self._get_dburi(uri) diff --git a/trytond/webdav/webdav.py b/trytond/webdav/webdav.py index 90c040edf0..6b548239e5 100644 --- a/trytond/webdav/webdav.py +++ b/trytond/webdav/webdav.py @@ -329,6 +329,13 @@ class Collection(ModelSQL, ModelView): return OBJECT return COLLECTION + def get_displayname(self, cursor, user, uri, context=None, cache=None): + object_name, object_id = self._uri2object(cursor, user, uri, + context=context, cache=cache) + model_obj = self.pool.get(object_name) + return model_obj.browse(cursor, user, object_id, context=context)\ + .rec_name + def get_contentlength(self, cursor, user, uri, context=None, cache=None): attachment_obj = self.pool.get('ir.attachment')