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)
Ejemplo n.º 3
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.º 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
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.
            # NOTE: this will _break_ any other service that would be registered
            # at the root path in future.
            base_path = False
            if config.get_misc('static-http', 'enable', False):
                base_path = config.get_misc('static-http', 'base_path', '/')
            if base_path and base_path == '/':
                dir_path = config.get_misc('static-http', 'dir_path', False)
            else:
                dir_path = addons.get_module_resource('document_webdav',
Ejemplo n.º 6
0
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.
            # NOTE: this will _break_ any other service that would be registered
            # at the root path in future.
            base_path = False
            if config.get_misc('static-http','enable', False):
                base_path = config.get_misc('static-http', 'base_path', '/')
            if base_path and base_path == '/':
                dir_path = config.get_misc('static-http', 'dir_path', False)
            else:
                dir_path = addons.get_module_resource('document_webdav','public_html')