diff options
| author | P. Christeas <p_christ@hol.gr> | 2010-06-23 13:54:37 +0300 |
|---|---|---|
| committer | P. Christeas <p_christ@hol.gr> | 2010-06-23 13:54:37 +0300 |
| commit | a26e8ae2eef6af0d33255f1081cfcc978c0c5138 (patch) | |
| tree | 580b536630a72156b0c32f8ddcfb6afb069426b5 /addons/document_webdav/webdav_server.py | |
| parent | 0be3a0757ca31d9abe8f78f86c3606200d546941 (diff) | |
Doc Webdav: Cleanup code, fix db listing, children paths.
This is a reshape of the code, since the porting. While the MultiHttpHandler
will strip the '/webdav' part of the path, the DAV code will try to
generate more paths without it. So, there must be consinstent functions
that will convert (at mk_prop_response and mk_propname_response) to the
full path or back. Also, only have one function that will strip the
db name from the path, so that we control the auth requirements (for the
purpose of database listings, which shouldn't require authentication).
bzr revid: p_christ@hol.gr-20100623105437-kmy0ccqihu5h9ydp
Diffstat (limited to 'addons/document_webdav/webdav_server.py')
| -rw-r--r-- | addons/document_webdav/webdav_server.py | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/addons/document_webdav/webdav_server.py b/addons/document_webdav/webdav_server.py index b907ed94df6..c920c84ea72 100644 --- a/addons/document_webdav/webdav_server.py +++ b/addons/document_webdav/webdav_server.py @@ -67,18 +67,17 @@ class DAVHandler(FixSendError,DAVRequestHandler): pass def get_db_from_path(self, uri): - if uri or uri == '/': - dbs = self.IFACE_CLASS.db_list() - res = len(dbs) and dbs[0] or False - else: - res = self.IFACE_CLASS.get_db(uri) + # interface class will handle all cases. + res = self.IFACE_CLASS.get_db(uri, allow_last=True) return res def setup(self): - davpath = '/'+config.get_misc('webdav','vdir','webdav') + self.davpath = '/'+config.get_misc('webdav','vdir','webdav') self.baseuri = "http://%s:%d/"% (self.server.server_name, self.server.server_port) self.IFACE_CLASS = openerp_dav_handler(self, self.verbose) + def get_davpath(self): + return self.davpath def log_message(self, format, *args): netsvc.Logger().notifyChannel('webdav', netsvc.LOG_DEBUG_RPC, format % args) @@ -164,8 +163,18 @@ class DAVHandler(FixSendError,DAVRequestHandler): self.send_body(None, '201', 'Created', '', headers=headers) +from service.http_server import reg_http_service,OpenERPAuthProvider + +class DAVAuthProvider(OpenERPAuthProvider): + def authenticate(self, db, user, passwd, client_address): + """ authenticate, but also allow the False db, meaning to skip + authentication when no db is specified. + """ + if db is False and user is None and passwd is None: + return True + return OpenERPAuthProvider.authenticate(self, db, user, passwd, client_address) + try: - from service.http_server import reg_http_service,OpenERPAuthProvider if (config.get_misc('webdav','enable',True)): directory = '/'+config.get_misc('webdav','vdir','webdav') @@ -180,7 +189,7 @@ try: conf = OpenDAVConfig(**_dc) handler._config = conf - reg_http_service(HTTPDir(directory,DAVHandler,OpenERPAuthProvider())) + reg_http_service(HTTPDir(directory,DAVHandler,DAVAuthProvider())) netsvc.Logger().notifyChannel('webdav', netsvc.LOG_INFO, "WebDAV service registered at path: %s/ "% directory) except Exception, e: logger = netsvc.Logger() |
