def init_well_known(): reps = RedirectHTTPHandler.redirect_paths num_svcs = config.get_misc('http-well-known', 'num_services', '0') for nsv in range(1, int(num_svcs) + 1): uri = config.get_misc('http-well-known', 'service_%d' % nsv, False) path = config.get_misc('http-well-known', 'path_%d' % nsv, False) if not (uri and path): continue reps['/' + uri] = path if int(num_svcs): reg_http_service('/.well-known', RedirectHTTPHandler)
def init_well_known(): reps = RedirectHTTPHandler.redirect_paths num_svcs = config.get_misc('http-well-known', 'num_services', '0') for nsv in range(1, int(num_svcs)+1): uri = config.get_misc('http-well-known', 'service_%d' % nsv, False) path = config.get_misc('http-well-known', 'path_%d' % nsv, False) if not (uri and path): continue reps['/'+uri] = path if int(num_svcs): reg_http_service('/.well-known', RedirectHTTPHandler)
def setup(self): self.davpath = '/' + config.get_misc('webdav', 'vdir', 'webdav') addr, port = self.server.server_name, self.server.server_port server_proto = getattr(self.server, 'proto', 'http').lower() # Too early here to use self.headers self.baseuri = "%s://%s:%d/" % (server_proto, addr, port) self.IFACE_CLASS = openerp_dav_handler(self, self.verbose)
def setup(self): self.davpath = '/'+config.get_misc('webdav','vdir','webdav') addr, port = self.server.server_name, self.server.server_port server_proto = getattr(self.server,'proto', 'http').lower() # Too early here to use self.headers self.baseuri = "%s://%s:%d/"% (server_proto, addr, port) self.IFACE_CLASS = openerp_dav_handler(self, self.verbose)
def init_principals_redirect(): """ Some devices like the iPhone will look under /principals/users/xxx for the user's properties. In OpenERP we _cannot_ have a stray /principals/... working path, since we have a database path and the /webdav/ component. So, the best solution is to redirect the url with 301. Luckily, it does work in the device. The trick is that we need to hard-code the database to use, either the one centrally defined in the config, or a "forced" one in the webdav section. """ dbname = config.get_misc('webdav', 'principal_dbname', False) if (not dbname) and not config.get_misc('webdav', 'no_principals_redirect', False): dbname = config.get('db_name', False) if dbname: PrincipalsRedirect.redirect_paths[''] = '/webdav/%s/principals' % dbname reg_http_service('/principals', PrincipalsRedirect) _logger.info( "Registered HTTP redirect handler for /principals to the %s db.", dbname)
def not_get_baseuri(self): baseuri = '/' if self.headers.has_key('Host'): uparts = list(urlparse.urlparse('/')) uparts[1] = self.headers['Host'] baseuri = urlparse.urlunparse(uparts) return baseuri def get_davpath(self): return '' try: if (config.get_misc('webdav', 'enable', True)): directory = '/' + config.get_misc('webdav', 'vdir', 'webdav') handler = DAVHandler verbose = config.get_misc('webdav', 'verbose', True) handler.debug = config.get_misc('webdav', 'debug', True) _dc = { 'verbose': verbose, 'directory': directory, 'lockemulation': True, } conf = OpenDAVConfig(**_dc) handler._config = conf reg_http_service(directory, DAVHandler, DAVAuthProvider) _logger.info("WebDAV service registered at path: %s/ " % directory)
def not_get_baseuri(self): baseuri = '/' if self.headers.has_key('Host'): uparts = list(urlparse.urlparse('/')) uparts[1] = self.headers['Host'] baseuri = urlparse.urlunparse(uparts) return baseuri def get_davpath(self): return '' try: if (config.get_misc('webdav','enable',True)): directory = '/'+config.get_misc('webdav','vdir','webdav') handler = DAVHandler verbose = config.get_misc('webdav','verbose',True) handler.debug = config.get_misc('webdav','debug',True) _dc = { 'verbose' : verbose, 'directory' : directory, 'lockemulation' : True, } conf = OpenDAVConfig(**_dc) handler._config = conf reg_http_service(directory, DAVHandler, DAVAuthProvider) _logger.info("WebDAV service registered at path: %s/ "% directory) if not (config.get_misc('webdav', 'no_root_hack', False)):