diff --git a/trytond/webdav/webdav.py b/trytond/webdav/webdav.py index 6a4cb6243b..b13602cf9f 100644 --- a/trytond/webdav/webdav.py +++ b/trytond/webdav/webdav.py @@ -219,25 +219,27 @@ class Collection(OSV): def get_creationdate(self, cursor, user, uri, context=None): object_name, object_id = self._uri2object(cursor, user, uri, context=context) - model_obj = self.pool.get(object_name) - if model_obj._log_access: - cursor.execute('SELECT EXTRACT(epoch FROM create_date) ' \ - 'FROM "' + model_obj._table +'" ' \ - 'WHERE id = %s', (object_id,)) - if cursor.rowcount: - return cursor.fetchone()[0] + if object_name: + model_obj = self.pool.get(object_name) + if model_obj._log_access: + cursor.execute('SELECT EXTRACT(epoch FROM create_date) ' \ + 'FROM "' + model_obj._table +'" ' \ + 'WHERE id = %s', (object_id,)) + if cursor.rowcount: + return cursor.fetchone()[0] return time.time() def get_lastmodified(self, cursor, user, uri, context=None): object_name, object_id = self._uri2object(cursor, user, uri, context=context) - model_obj = self.pool.get(object_name) - if model_obj._log_access and object_id: - cursor.execute('SELECT EXTRACT(epoch FROM write_date) ' \ - 'FROM "' + model_obj._table +'" ' \ - 'WHERE id = %s', (object_id,)) - if cursor.rowcount: - return cursor.fetchone()[0] + if object_name: + model_obj = self.pool.get(object_name) + if model_obj._log_access and object_id: + cursor.execute('SELECT EXTRACT(epoch FROM write_date) ' \ + 'FROM "' + model_obj._table +'" ' \ + 'WHERE id = %s', (object_id,)) + if cursor.rowcount: + return cursor.fetchone()[0] return time.time() def get_data(self, cursor, user, uri, context=None): @@ -342,6 +344,8 @@ class Collection(OSV): from DAV.errors import DAV_Forbidden object_name, object_id = self._uri2object(cursor, user, uri, context=context) + if not object_name: + raise DAV_Forbidden if object_name != 'ir.attachment' \ or not object_id: raise DAV_Forbidden