Add creation/modified date and fix trailing /
This commit is contained in:
1 parent
08e261173c
commit
b8c554b05e
2 files changed
+43
-1
No files matched your search
@@ -1,6 +1,7 @@
|
||||
"WebDAV"
|
||||
import os
|
||||
import base64
|
||||
import time
|
||||
from trytond.osv import fields, OSV
|
||||
from trytond.version import PACKAGE, VERSION, WEBSITE
|
||||
|
||||
@@ -131,6 +132,28 @@ class Directory(OSV):
|
||||
return self.ext2mime.get(ext, 'application/octet-stream')
|
||||
return "application/octet-stream"
|
||||
|
||||
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 = %d', (object_id,))
|
||||
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:
|
||||
cursor.execute('SELECT EXTRACT(epoch FROM write_date) ' \
|
||||
'FROM "' + model_obj._table +'" ' \
|
||||
'WHERE id = %d', (object_id,))
|
||||
return cursor.fetchone()[0]
|
||||
return time.time()
|
||||
|
||||
def get_data(self, cursor, user, uri, context=None):
|
||||
from DAV.errors import DAV_NotFound
|
||||
if uri:
|
||||
|
||||
+20
-1
@@ -1,6 +1,7 @@
|
||||
import urlparse
|
||||
import socket
|
||||
import base64
|
||||
import time
|
||||
from DAV import AuthServer, WebDAVServer, iface
|
||||
from DAV.errors import *
|
||||
from DAV.constants import COLLECTION, OBJECT
|
||||
@@ -35,7 +36,7 @@ class TrytonDAVInterface(iface.dav_interface):
|
||||
pool = pooler.get_pool(dbname)
|
||||
cursor = pooler.get_db(dbname).cursor()
|
||||
directory_obj = pool.get('webdav.directory')
|
||||
if uri[:-1] != '/':
|
||||
if uri[-1:] != '/':
|
||||
uri += '/'
|
||||
for child in directory_obj.get_childs(cursor, USER_ID, dburi):
|
||||
res.append(urlparse.urljoin(self.baseuri, uri + child))
|
||||
@@ -102,6 +103,24 @@ class TrytonDAVInterface(iface.dav_interface):
|
||||
directory_obj = pool.get('webdav.directory')
|
||||
return directory_obj.get_contenttype(cursor, USER_ID, dburi)
|
||||
|
||||
def get_creationdate(self, uri):
|
||||
dbname, dburi = self._get_dburi(uri)
|
||||
if not dbname or not dburi:
|
||||
return time.time()
|
||||
pool = pooler.get_pool(dbname)
|
||||
cursor = pooler.get_db(dbname).cursor()
|
||||
directory_obj = pool.get('webdav.directory')
|
||||
return directory_obj.get_creationdate(cursor, USER_ID, dburi)
|
||||
|
||||
def get_lastmodified(self, uri):
|
||||
dbname, dburi = self._get_dburi(uri)
|
||||
if not dbname or not dburi:
|
||||
return time.time()
|
||||
pool = pooler.get_pool(dbname)
|
||||
cursor = pooler.get_db(dbname).cursor()
|
||||
directory_obj = pool.get('webdav.directory')
|
||||
return directory_obj.get_lastmodified(cursor, USER_ID, dburi)
|
||||
|
||||
def exists(self, uri):
|
||||
dbname, dburi = self._get_dburi(uri)
|
||||
if not dbname or not dburi:
|
||||
|
||||
Reference in new issue
Block a user