Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
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):
        if http_server.reg_http_service(HTTPDir('/.well-known', RedirectHTTPHandler)):
            logging.getLogger("web-services").info("Registered HTTP redirect handler at /.well-known" )
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
 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()
     try:
         if hasattr(self.request, "getsockname"):
             addr, port = self.request.getsockname()
     except Exception, e:
         self.log_error("Cannot calculate own address: %s", e)
Ejemplo n.º 6
0
 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()
     try:
         if hasattr(self.request, 'getsockname'):
             addr, port = self.request.getsockname()
     except Exception, e:
         self.log_error("Cannot calculate own address: %s" , e)
Ejemplo n.º 7
0
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)
        logging.getLogger("web-services").info(
            "Registered HTTP redirect handler for /principals to the %s db.",
            dbname)
Ejemplo n.º 8
0
    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)):
            # Now, replace the static http handler with the dav-enabled one.
            # If a static-http service has been specified for our server, then
            # read its configuration and use that dir_path.
Ejemplo n.º 9
0
    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)):
Ejemplo n.º 10
0
    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)):