Improve webdav for wrong uri

This commit is contained in:
Cédric Krier committed 2008-07-23 23:18:50 +02:00
1 parent 068ca16930
commit 11cfae3218
1 file changed
+18 -14
+18 -14
View File
@@ -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