[FIX] document_webdav : Replace <TAB> with four <WHITE SPACE>
[odoo/odoo.git] / addons / document_webdav / webdav_server.py
1 # -*- encoding: utf-8 -*-
2
3 #
4 # Copyright P. Christeas <p_christ@hol.gr> 2008,2009
5 #
6 #
7 # WARNING: This program as such is intended to be used by professional
8 # programmers who take the whole responsability of assessing all potential
9 # consequences resulting from its eventual inadequacies and bugs
10 # End users who are looking for a ready-to-use solution with commercial
11 # garantees and support are strongly adviced to contract a Free Software
12 # Service Company
13 #
14 # This program is Free Software; you can redistribute it and/or
15 # modify it under the terms of the GNU General Public License
16 # as published by the Free Software Foundation; either version 2
17 # of the License, or (at your option) any later version.
18 #
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 # GNU General Public License for more details.
23 #
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write to the Free Software
26 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
27 ###############################################################################
28
29
30 import netsvc
31 from dav_fs import tinydav_handler
32 from tools.config import config
33 from DAV.WebDAVServer import DAVRequestHandler
34 from service.websrv_lib import HTTPDir,FixSendError
35
36 class DAVHandler(FixSendError,DAVRequestHandler):
37     verbose = False
38     
39     def get_userinfo(self,user,pw):
40         print "get_userinfo"
41         return False
42     def _log(self, message):
43         netsvc.Logger().notifyChannel("webdav",netsvc.LOG_DEBUG,message)
44     
45     def handle(self):
46         pass
47
48     def finish(self):
49         pass
50
51     def setup(self):
52         davpath = '/'+config.get_misc('webdav','vdir','webdav')+'/'
53         self.baseuri = "http://%s:%d%s"% (self.server.server_name,self.server.server_port,davpath)
54         self.IFACE_CLASS  = tinydav_handler(self)
55         pass
56     
57     def log_message(self, format, *args):
58         netsvc.Logger().notifyChannel('webdav',netsvc.LOG_DEBUG_RPC,format % args)
59
60     def log_error(self, format, *args):
61         netsvc.Logger().notifyChannel('xmlrpc',netsvc.LOG_WARNING,format % args)
62
63
64 try:
65     from service.http_server import reg_http_service,OpenERPAuthProvider
66     if (config.get_misc('webdav','enable',False)):
67         davpath = '/'+config.get_misc('webdav','vdir','webdav')+'/'
68         handler = DAVHandler
69         handler.verbose = config.get_misc('webdav','verbose',True)
70         handler.debug = config.get_misc('webdav','debug',True)
71         reg_http_service(HTTPDir(davpath,DAVHandler,OpenERPAuthProvider()))
72         netsvc.Logger().notifyChannel('webdav',netsvc.LOG_INFO,"WebDAV service registered at path: %s/ "% davpath)
73 except Exception, e:
74     logger = netsvc.Logger()
75     logger.notifyChannel('webdav', netsvc.LOG_ERROR, 'Cannot launch webdav: %s' % e)
76
77 #eof
78
79
80