コード例 #1
0
def _get_config_functionality(name, registered, config):
    result = None

    if registered:
        result = get_setting(config, ('functionalities', 'registered', name))
    if result is None:
        result = get_setting(config, ('functionalities', 'anonymous', name))

    if result is None:
        result = []
    elif not isinstance(result, list):
        result = [result]

    return result
コード例 #2
0
def _get_config_functionality(name, registered, config):
    result = None

    if registered:
        result = get_setting(
            config, ("functionalities", "registered", name))
    if result is None:
        result = get_setting(
            config, ("functionalities", "anonymous", name))

    if result is None:
        result = []
    elif not isinstance(result, list):
        result = [result]

    return result
コード例 #3
0
ファイル: entry.py プロジェクト: pgiraud/c2cgeoportal
 def _functionality(self):
     functionality = {}
     for func in get_setting(
             self.settings,
             ('functionalities', 'available_in_templates'), []):
         functionality[func] = get_functionality(
             func, self.settings, self.request)
     return functionality
コード例 #4
0
ファイル: functionality.py プロジェクト: vovoma/c2cgeoportal
def _get_config_functionality(name, registered, types, request, errors):
    result = None

    if registered:
        result = get_setting(
            request.registry.settings, ("functionalities", "registered", name))
    if result is None:
        result = get_setting(
            request.registry.settings, ("functionalities", "anonymous", name))

    if result is None:
        result = []
    elif not isinstance(result, list):
        result = [result]

    result = [get_typed(name, r, types, request, errors) for r in result]
    return [r for r in result if r is not None]
コード例 #5
0
 def _functionality(self):
     functionality = {}
     for func in get_setting(self.settings,
                             ('functionalities', 'available_in_templates'),
                             []):
         functionality[func] = get_functionality(func, self.settings,
                                                 self.request)
     return functionality
コード例 #6
0
def _get_config_functionality(name, registered, types, request, errors):
    result = None

    if registered:
        result = get_setting(
            request.registry.settings, ("functionalities", "registered", name))
    if result is None:
        result = get_setting(
            request.registry.settings, ("functionalities", "anonymous", name))

    if result is None:
        result = []
    elif not isinstance(result, list):
        result = [result]

    result = [get_typed(name, r, types, request, errors) for r in result]
    return [r for r in result if r is not None]
コード例 #7
0
ファイル: entry.py プロジェクト: fredj/c2cgeoportal
 def _functionality_cached(self, role):
     functionality = {}
     for func in get_setting(
             self.settings,
             ("functionalities", "available_in_templates"), []
     ):
         functionality[func] = get_functionality(
             func, self.settings, self.request
         )
     return functionality
コード例 #8
0
ファイル: __init__.py プロジェクト: CDTRH/c2cgeoportal
def includeme(config):
    """ This function returns a Pyramid WSGI application.
    """

    # update the settings object from the YAML application config file
    settings = config.get_settings()
    settings.update(yaml.load(file(settings.get('app.cfg'))))

    global srid
    global schema
    global parentschema
    global formalchemy_language
    global formalchemy_default_zoom
    global formalchemy_default_x
    global formalchemy_default_y
    global formalchemy_available_functionalities

    config.set_request_property(
        get_user_from_request, name='user', reify=True)

    # configure 'locale' dir as the translation dir for c2cgeoportal app
    config.add_translation_dirs('c2cgeoportal:locale/')

    # initialize database
    engine = sqlalchemy.engine_from_config(
        config.get_settings(),
        'sqlalchemy.')
    sqlahelper.add_engine(engine)
    config.include(pyramid_tm.includeme)

    # initialize the dbreflection module
    dbreflection.init(engine)

    # dogpile.cache configuration
    caching.init_region(settings['cache'])
    caching.invalidate_region()

    # bind the mako renderer to other file extensions
    config.add_renderer('.html', mako_renderer_factory)
    config.add_renderer('.js', mako_renderer_factory)

    # add the "geojson" renderer
    config.add_renderer('geojson', GeoJSON())

    # add decimal json renderer
    config.add_renderer('decimaljson', DecimalJSON())

    # add the "xsd" renderer
    config.add_renderer('xsd', XSD(
        sequence_callback=dbreflection._xsd_sequence_callback))

    # add the set_user_validator directive, and set a default user
    # validator
    config.add_directive('set_user_validator', set_user_validator)
    config.set_user_validator(default_user_validator)

    # add an OGCProxy view
    config.add_route(
        'ogcproxy', '/ogcproxy',
        custom_predicates=(ogcproxy_route_predicate,))
    config.add_view('papyrus_ogcproxy.views:ogcproxy', route_name='ogcproxy')

    # add routes to the mapserver proxy
    config.add_route(
        'mapserverproxy', '/mapserv_proxy',
        custom_predicates=(mapserverproxy_route_predicate,),
        pregenerator=MultiDomainPregenerator())

    # add routes to csv view
    config.add_route('csvecho', '/csv')

    # add routes to the echo service
    config.add_route('echo', '/echo')

    # add routes to the entry view class
    config.add_route('home', '/')
    config.add_route('viewer', '/viewer.js')
    config.add_route('edit', '/edit')
    config.add_route('edit.js', '/edit.js')
    config.add_route('routing', '/routing')
    config.add_route('routing.js', '/routing.js')
    config.add_route('loginform', '/login.html')
    config.add_route('login', '/login')
    config.add_route('logout', '/logout')
    config.add_route('loginchange', '/loginchange')
    config.add_route('testi18n', '/testi18n.html')
    config.add_route('apijs', '/api.js')
    config.add_route('xapijs', '/xapi.js')
    config.add_route('apihelp', '/apihelp.html')
    config.add_route('xapihelp', '/xapihelp.html')
    config.add_route('themes', '/themes')
    # permalink theme: recover the theme for generating custom viewer.js url
    config.add_route('permalinktheme', '/theme/*themes')

    # checker routes, Checkers are web services to test and assess that
    # the application is correctly functioning.
    # These web services are used by tools like (nagios).
    config.add_route('checker_main', '/checker_main')
    config.add_route('checker_viewer', '/checker_viewer')
    config.add_route('checker_edit', '/checker_edit')
    config.add_route('checker_edit_js', '/checker_edit_js')
    config.add_route('checker_api', '/checker_api')
    config.add_route('checker_xapi', '/checker_xapi')
    config.add_route('checker_printcapabilities', '/checker_printcapabilities')
    config.add_route('checker_pdf', '/checker_pdf')
    config.add_route('checker_fts', '/checker_fts')
    config.add_route('checker_wmscapabilities', '/checker_wmscapabilities')
    config.add_route('checker_wfscapabilities', '/checker_wfscapabilities')
    # collector
    config.add_route('check_collector', '/check_collector')

    # print proxy routes
    config.add_route('printproxy', '/printproxy')
    config.add_route('printproxy_info', '/printproxy/info.json')
    config.add_route('printproxy_create', '/printproxy/create.json')
    config.add_route('printproxy_get', '/printproxy/{file}.printout')

    # full text search routes
    config.add_route('fulltextsearch', '/fulltextsearch')

    # Access to raster data
    config.add_route('raster', '/raster')
    config.add_route('profile.csv', '/profile.csv')
    config.add_route('profile.json', '/profile.json')

    # shortener
    config.add_route('shortener_create', '/short/create')
    config.add_route('shortener_get', '/short/{ref}')

    # add routes for the "layers" web service
    config.add_route(
        'layers_count', '/layers/{layer_id:\\d+}/count',
        request_method='GET')
    config.add_route(
        'layers_metadata', '/layers/{layer_id:\\d+}/md.xsd',
        request_method='GET')
    config.add_route(
        'layers_read_many',
        '/layers/{layer_id:\\d+,?(\\d+,)*\\d*$}',
        request_method='GET')  # supports URLs like /layers/1,2,3
    config.add_route(
        'layers_read_one', '/layers/{layer_id:\\d+}/{feature_id}',
        request_method='GET')
    config.add_route(
        'layers_create', '/layers/{layer_id:\\d+}',
        request_method='POST')
    config.add_route(
        'layers_update', '/layers/{layer_id:\\d+}/{feature_id}',
        request_method='PUT')
    config.add_route(
        'layers_delete', '/layers/{layer_id:\\d+}/{feature_id}',
        request_method='DELETE')
    config.add_route(
        'layers_enumerate_attribute_values',
        '/layers/{layer_name}/values/{field_name}',
        request_method='GET')
    # there's no view corresponding to that route, it is to be used from
    # mako templates to get the root of the "layers" web service
    config.add_route('layers_root', '/layers/')

    # pyramid_formalchemy's configuration
    config.include('pyramid_formalchemy')
    config.include('fa.jquery')

    # define the srid, schema and parentschema
    # as global variables to be usable in the model
    srid = config.get_settings()['srid']
    schema = config.get_settings()['schema']
    parentschema = config.get_settings()['parentschema']
    settings = config.get_settings()
    formalchemy_default_zoom = get_setting(
        settings,
        ('admin_interface', 'map_zoom'), formalchemy_default_zoom)
    formalchemy_default_x = get_setting(
        settings,
        ('admin_interface', 'map_x'), formalchemy_default_x)
    formalchemy_default_y = get_setting(
        settings,
        ('admin_interface', 'map_y'), formalchemy_default_y)
    formalchemy_available_functionalities = get_setting(
        settings,
        ('admin_interface', 'available_functionalities'),
        formalchemy_available_functionalities)

    # scan view decorator for adding routes
    config.scan(ignore='c2cgeoportal.tests')

    config.registry.registerUtility(
        MultiDomainStaticURLInfo(), IStaticURLInfo)
    # add the static view (for static resources)
    config.add_static_view(
        'static', 'c2cgeoportal:static',
        cache_max_age=int(settings["default_max_age"])
    )
コード例 #9
0
ファイル: pyramid_.py プロジェクト: juliensam/c2cgeoportal
def includeme(config):
    """ This function returns a Pyramid WSGI application.
    """

    # update the settings object from the YAML application config file
    settings = config.get_settings()
    settings.update(c2c.template.get_config(settings.get("app.cfg")))

    call_hook(settings, "after_settings", settings)

    config.add_request_method(_create_get_user_from_request(settings),
                              name="user",
                              property=True)

    # configure 'locale' dir as the translation dir for c2cgeoportal app
    config.add_translation_dirs("c2cgeoportal:locale/")

    # initialize database
    engine = sqlalchemy.engine_from_config(settings, "sqlalchemy.")
    sqlahelper.add_engine(engine)
    config.include(pyramid_tm.includeme)
    config.include("pyramid_closure")

    if "sqlalchemy_slave.url" in settings and \
            settings["sqlalchemy.url"] != settings["sqlalchemy_slave.url"]:  # pragma: nocover
        # Setup a slave DB connection and add a tween to switch between it and the default one.
        log.info("Using a slave DB for reading")
        engine_slave = sqlalchemy.engine_from_config(config.get_settings(),
                                                     "sqlalchemy_slave.")
        sqlahelper.add_engine(engine_slave, name="slave")
        config.add_tween("c2cgeoportal.models.db_chooser_tween_factory",
                         over="pyramid_tm.tm_tween_factory")

    # initialize the dbreflection module
    dbreflection.init(engine)

    # dogpile.cache configuration
    caching.init_region(settings["cache"])
    caching.invalidate_region()

    # Register a tween to get back the cache buster path.
    config.add_tween("c2cgeoportal.lib.cacheversion.CachebusterTween")

    # bind the mako renderer to other file extensions
    add_mako_renderer(config, ".html")
    add_mako_renderer(config, ".js")
    config.include("pyramid_chameleon")

    # add the "geojson" renderer
    config.add_renderer("geojson", GeoJSON())

    # add decimal json renderer
    config.add_renderer("decimaljson", DecimalJSON())

    # add the "xsd" renderer
    config.add_renderer(
        "xsd", XSD(sequence_callback=dbreflection._xsd_sequence_callback))

    # add the set_user_validator directive, and set a default user
    # validator
    config.add_directive("set_user_validator", set_user_validator)
    config.set_user_validator(default_user_validator)

    if settings.get("ogcproxy_enable", False):  # pragma: no cover
        # add an OGCProxy view
        config.add_route_predicate("ogc_server", OgcproxyRoutePredicate)
        config.add_route("ogcproxy", "/ogcproxy", ogc_server=True)
        config.add_view("papyrus_ogcproxy.views:ogcproxy",
                        route_name="ogcproxy")

    # add routes to the mapserver proxy
    config.add_route_predicate("mapserverproxy", MapserverproxyRoutePredicate)
    config.add_route(
        "mapserverproxy",
        "/mapserv_proxy",
        mapserverproxy=True,
        pregenerator=C2CPregenerator(role=True),
    )

    # add route to the tinyows proxy
    config.add_route(
        "tinyowsproxy",
        "/tinyows_proxy",
        pregenerator=C2CPregenerator(role=True),
    )

    # add routes to csv view
    config.add_route("csvecho", "/csv", request_method="POST")

    # add route to the export GPX/KML view
    config.add_route("exportgpxkml", "/exportgpxkml")

    # add routes to the echo service
    config.add_route("echo", "/echo", request_method="POST")

    # add routes to the entry view class
    config.add_route("base", "/", static=True)
    config.add_route("loginform", "/login.html", request_method="GET")
    add_cors_route(config, "/login", "login")
    config.add_route("login", "/login", request_method="POST")
    add_cors_route(config, "/logout", "login")
    config.add_route("logout", "/logout", request_method="GET")
    add_cors_route(config, "/loginchange", "login")
    config.add_route("loginchange", "/loginchange", request_method="POST")
    add_cors_route(config, "/loginresetpassword", "login")
    config.add_route("loginresetpassword",
                     "/loginresetpassword",
                     request_method="POST")
    add_cors_route(config, "/loginuser", "login")
    config.add_route("loginuser", "/loginuser", request_method="GET")
    config.add_route("testi18n", "/testi18n.html", request_method="GET")
    config.add_route("apijs", "/api.js", request_method="GET")
    config.add_route("xapijs", "/xapi.js", request_method="GET")
    config.add_route("apihelp", "/apihelp.html", request_method="GET")
    config.add_route("xapihelp", "/xapihelp.html", request_method="GET")
    config.add_route(
        "themes",
        "/themes",
        request_method="GET",
        pregenerator=C2CPregenerator(role=True),
    )
    config.add_route("invalidate", "/invalidate", request_method="GET")

    # checker routes, Checkers are web services to test and assess that
    # the application is correctly functioning.
    # These web services are used by tools like (nagios).
    config.add_route("checker_routes", "/checker_routes", request_method="GET")
    config.add_route("checker_lang_files",
                     "/checker_lang_files",
                     request_method="GET")
    config.add_route("checker_pdf3", "/checker_pdf3", request_method="GET")
    config.add_route("checker_fts", "/checker_fts", request_method="GET")
    config.add_route("checker_theme_errors",
                     "/checker_theme_errors",
                     request_method="GET")
    config.add_route("checker_phantomjs",
                     "/checker_phantomjs",
                     request_method="GET")
    # collector
    config.add_route("check_collector",
                     "/check_collector",
                     request_method="GET")

    # print proxy routes
    config.add_route("printproxy", "/printproxy", request_method="HEAD")
    add_cors_route(config, "/printproxy/*all", "print")
    config.add_route(
        "printproxy_capabilities",
        "/printproxy/capabilities.json",
        request_method="GET",
        pregenerator=C2CPregenerator(role=True),
    )
    config.add_route("printproxy_report_create",
                     "/printproxy/report.{format}",
                     request_method="POST",
                     header=JSON_CONTENT_TYPE)
    config.add_route("printproxy_status",
                     "/printproxy/status/{ref}.json",
                     request_method="GET")
    config.add_route("printproxy_cancel",
                     "/printproxy/cancel/{ref}",
                     request_method="DELETE")
    config.add_route("printproxy_report_get",
                     "/printproxy/report/{ref}",
                     request_method="GET")

    # full text search routes
    add_cors_route(config, "/fulltextsearch", "fulltextsearch")
    config.add_route("fulltextsearch", "/fulltextsearch")

    # Access to raster data
    add_cors_route(config, "/raster", "raster")
    config.add_route("raster", "/raster", request_method="GET")

    add_cors_route(config, "/profile.{ext}", "profile")
    config.add_route("profile.csv", "/profile.csv", request_method="POST")
    config.add_route("profile.json", "/profile.json", request_method="POST")

    # shortener
    add_cors_route(config, "/short/create", "shortner")
    config.add_route("shortener_create",
                     "/short/create",
                     request_method="POST")
    config.add_route("shortener_get", "/short/{ref}", request_method="GET")

    # Geometry processing
    config.add_route("difference", "/difference", request_method="POST")

    # PDF report tool
    config.add_route("pdfreport",
                     "/pdfreport/{layername}/{id}",
                     request_method="GET")

    # add routes for the "layers" web service
    add_cors_route(config, "/layers/*all", "layers")
    config.add_route("layers_count",
                     "/layers/{layer_id:\\d+}/count",
                     request_method="GET")
    config.add_route(
        "layers_metadata",
        "/layers/{layer_id:\\d+}/md.xsd",
        request_method="GET",
        pregenerator=C2CPregenerator(role=True),
    )
    config.add_route("layers_read_many",
                     "/layers/{layer_id:\\d+,?(\\d+,)*\\d*$}",
                     request_method="GET")  # supports URLs like /layers/1,2,3
    config.add_route("layers_read_one",
                     "/layers/{layer_id:\\d+}/{feature_id}",
                     request_method="GET")
    config.add_route("layers_create",
                     "/layers/{layer_id:\\d+}",
                     request_method="POST",
                     header=JSON_CONTENT_TYPE)
    config.add_route("layers_update",
                     "/layers/{layer_id:\\d+}/{feature_id}",
                     request_method="PUT",
                     header=JSON_CONTENT_TYPE)
    config.add_route("layers_delete",
                     "/layers/{layer_id:\\d+}/{feature_id}",
                     request_method="DELETE")
    config.add_route(
        "layers_enumerate_attribute_values",
        "/layers/{layer_name}/values/{field_name}",
        request_method="GET",
        pregenerator=C2CPregenerator(),
    )
    # there's no view corresponding to that route, it is to be used from
    # mako templates to get the root of the "layers" web service
    config.add_route("layers_root", "/layers/", request_method="HEAD")

    # Resource proxy (load external url, useful when loading non https content)
    config.add_route("resourceproxy", "/resourceproxy", request_method="GET")

    # pyramid_formalchemy's configuration
    config.include("pyramid_formalchemy")
    config.include("fa.jquery")

    # define the srid, schema and parentschema
    # as global variables to be usable in the model
    c2cgeoportal.srid = settings["srid"]
    c2cgeoportal.schema = settings["schema"]
    c2cgeoportal.parentschema = settings["parentschema"]
    c2cgeoportal.formalchemy_default_zoom = get_setting(
        settings, ("admin_interface", "map_zoom"),
        c2cgeoportal.formalchemy_default_zoom)
    c2cgeoportal.formalchemy_default_x = get_setting(
        settings, ("admin_interface", "map_x"),
        c2cgeoportal.formalchemy_default_x)
    c2cgeoportal.formalchemy_default_y = get_setting(
        settings, ("admin_interface", "map_y"),
        c2cgeoportal.formalchemy_default_y)
    c2cgeoportal.formalchemy_available_functionalities = get_setting(
        settings, ("admin_interface", "available_functionalities"),
        c2cgeoportal.formalchemy_available_functionalities)
    c2cgeoportal.formalchemy_available_metadata = get_setting(
        settings, ("admin_interface", "available_metadata"),
        c2cgeoportal.formalchemy_available_metadata)
    c2cgeoportal.formalchemy_available_metadata = [
        e if isinstance(e, basestring) else e.get("name")
        for e in c2cgeoportal.formalchemy_available_metadata
    ]

    config.add_route("checker_all", "/checker_all", request_method="GET")

    config.add_route("version_json", "/version.json", request_method="GET")

    stats.init(config)

    # scan view decorator for adding routes
    config.scan(ignore=["c2cgeoportal.tests", "c2cgeoportal.scripts"])

    if "subdomains" in settings:  # pragma: no cover
        config.registry.registerUtility(MultiDomainStaticURLInfo(),
                                        IStaticURLInfo)

    # add the static view (for static resources)
    _add_static_view(config, "static", "c2cgeoportal:static")
    _add_static_view(config, "project", "c2cgeoportal:project")

    add_admin_interface(config)
    add_static_view(config)

    # Handles the other HTTP errors raised by the views. Without that,
    # the client receives a status=200 without content.
    config.add_view(error_handler, context=HTTPException)

    _log_versions(settings)
コード例 #10
0
def includeme(config):
    """ This function returns a Pyramid WSGI application.
    """

    # update the settings object from the YAML application config file
    settings = config.get_settings()
    settings.update(c2c.template.get_config(settings.get("app.cfg")))

    call_hook(settings, "after_settings", settings)

    config.add_request_method(_create_get_user_from_request(settings),
                              name="user", property=True)

    # configure 'locale' dir as the translation dir for c2cgeoportal app
    config.add_translation_dirs("c2cgeoportal:locale/")

    # initialize database
    engine = sqlalchemy.engine_from_config(
        settings,
        "sqlalchemy.")
    sqlahelper.add_engine(engine)
    config.include(pyramid_tm.includeme)
    config.include("pyramid_closure")

    if "sqlalchemy_slave.url" in settings and \
            settings["sqlalchemy.url"] != settings["sqlalchemy_slave.url"]:  # pragma: nocover
        # Setup a slave DB connection and add a tween to switch between it and the default one.
        log.info("Using a slave DB for reading")
        engine_slave = sqlalchemy.engine_from_config(config.get_settings(), "sqlalchemy_slave.")
        sqlahelper.add_engine(engine_slave, name="slave")
        config.add_tween("c2cgeoportal.models.db_chooser_tween_factory",
                         over="pyramid_tm.tm_tween_factory")

    # initialize the dbreflection module
    dbreflection.init(engine)

    # dogpile.cache configuration
    caching.init_region(settings["cache"])
    caching.invalidate_region()

    # Register a tween to get back the cache buster path.
    config.add_tween("c2cgeoportal.lib.cacheversion.CachebusterTween")

    # bind the mako renderer to other file extensions
    add_mako_renderer(config, ".html")
    add_mako_renderer(config, ".js")
    config.include("pyramid_chameleon")

    # add the "geojson" renderer
    config.add_renderer("geojson", GeoJSON())

    # add decimal json renderer
    config.add_renderer("decimaljson", DecimalJSON())

    # add the "xsd" renderer
    config.add_renderer("xsd", XSD(
        sequence_callback=dbreflection._xsd_sequence_callback
    ))

    # add the set_user_validator directive, and set a default user
    # validator
    config.add_directive("set_user_validator", set_user_validator)
    config.set_user_validator(default_user_validator)

    if settings.get("ogcproxy_enable", False):  # pragma: no cover
        # add an OGCProxy view
        config.add_route_predicate("ogc_server", OgcproxyRoutePredicate)
        config.add_route(
            "ogcproxy", "/ogcproxy",
            ogc_server=True
        )
        config.add_view("papyrus_ogcproxy.views:ogcproxy", route_name="ogcproxy")

    # add routes to the mapserver proxy
    config.add_route_predicate("mapserverproxy", MapserverproxyRoutePredicate)
    config.add_route(
        "mapserverproxy", "/mapserv_proxy",
        mapserverproxy=True, pregenerator=C2CPregenerator(role=True),
    )

    # add route to the tinyows proxy
    config.add_route(
        "tinyowsproxy", "/tinyows_proxy",
        pregenerator=C2CPregenerator(role=True),
    )

    # add routes to csv view
    config.add_route("csvecho", "/csv", request_method="POST")

    # add route to the export GPX/KML view
    config.add_route("exportgpxkml", "/exportgpxkml")

    # add routes to the echo service
    config.add_route("echo", "/echo", request_method="POST")

    # add routes to the entry view class
    config.add_route("base", "/", static=True)
    config.add_route("loginform", "/login.html", request_method="GET")
    add_cors_route(config, "/login", "login")
    config.add_route("login", "/login", request_method="POST")
    add_cors_route(config, "/logout", "login")
    config.add_route("logout", "/logout", request_method="GET")
    add_cors_route(config, "/loginchange", "login")
    config.add_route("loginchange", "/loginchange", request_method="POST")
    add_cors_route(config, "/loginresetpassword", "login")
    config.add_route("loginresetpassword", "/loginresetpassword", request_method="POST")
    add_cors_route(config, "/loginuser", "login")
    config.add_route("loginuser", "/loginuser", request_method="GET")
    config.add_route("testi18n", "/testi18n.html", request_method="GET")
    config.add_route("apijs", "/api.js", request_method="GET")
    config.add_route("xapijs", "/xapi.js", request_method="GET")
    config.add_route("apihelp", "/apihelp.html", request_method="GET")
    config.add_route("xapihelp", "/xapihelp.html", request_method="GET")
    config.add_route(
        "themes", "/themes",
        request_method="GET",
        pregenerator=C2CPregenerator(role=True),
    )
    config.add_route("invalidate", "/invalidate", request_method="GET")

    # checker routes, Checkers are web services to test and assess that
    # the application is correctly functioning.
    # These web services are used by tools like (nagios).
    config.add_route("checker_routes", "/checker_routes", request_method="GET")
    config.add_route("checker_lang_files", "/checker_lang_files", request_method="GET")
    config.add_route("checker_pdf3", "/checker_pdf3", request_method="GET")
    config.add_route("checker_fts", "/checker_fts", request_method="GET")
    config.add_route("checker_theme_errors", "/checker_theme_errors", request_method="GET")
    config.add_route("checker_phantomjs", "/checker_phantomjs", request_method="GET")
    # collector
    config.add_route("check_collector", "/check_collector", request_method="GET")

    # print proxy routes
    config.add_route("printproxy", "/printproxy", request_method="HEAD")
    add_cors_route(config, "/printproxy/*all", "print")
    config.add_route(
        "printproxy_capabilities", "/printproxy/capabilities.json",
        request_method="GET", pregenerator=C2CPregenerator(role=True),
    )
    config.add_route(
        "printproxy_report_create", "/printproxy/report.{format}",
        request_method="POST", header=JSON_CONTENT_TYPE
    )
    config.add_route(
        "printproxy_status", "/printproxy/status/{ref}.json",
        request_method="GET"
    )
    config.add_route(
        "printproxy_cancel", "/printproxy/cancel/{ref}",
        request_method="DELETE"
    )
    config.add_route(
        "printproxy_report_get", "/printproxy/report/{ref}",
        request_method="GET"
    )

    # full text search routes
    add_cors_route(config, "/fulltextsearch", "fulltextsearch")
    config.add_route("fulltextsearch", "/fulltextsearch")

    # Access to raster data
    add_cors_route(config, "/raster", "raster")
    config.add_route("raster", "/raster", request_method="GET")

    add_cors_route(config, "/profile.{ext}", "profile")
    config.add_route("profile.csv", "/profile.csv", request_method="POST")
    config.add_route("profile.json", "/profile.json", request_method="POST")

    # shortener
    add_cors_route(config, "/short/create", "shortner")
    config.add_route("shortener_create", "/short/create", request_method="POST")
    config.add_route("shortener_get", "/short/{ref}", request_method="GET")

    # Geometry processing
    config.add_route("difference", "/difference", request_method="POST")

    # PDF report tool
    config.add_route("pdfreport", "/pdfreport/{layername}/{id}", request_method="GET")

    # add routes for the "layers" web service
    add_cors_route(config, "/layers/*all", "layers")
    config.add_route(
        "layers_count", "/layers/{layer_id:\\d+}/count",
        request_method="GET"
    )
    config.add_route(
        "layers_metadata", "/layers/{layer_id:\\d+}/md.xsd",
        request_method="GET",
        pregenerator=C2CPregenerator(role=True),
    )
    config.add_route(
        "layers_read_many",
        "/layers/{layer_id:\\d+,?(\\d+,)*\\d*$}",
        request_method="GET")  # supports URLs like /layers/1,2,3
    config.add_route(
        "layers_read_one", "/layers/{layer_id:\\d+}/{feature_id}",
        request_method="GET")
    config.add_route(
        "layers_create", "/layers/{layer_id:\\d+}",
        request_method="POST", header=JSON_CONTENT_TYPE)
    config.add_route(
        "layers_update", "/layers/{layer_id:\\d+}/{feature_id}",
        request_method="PUT", header=JSON_CONTENT_TYPE)
    config.add_route(
        "layers_delete", "/layers/{layer_id:\\d+}/{feature_id}",
        request_method="DELETE")
    config.add_route(
        "layers_enumerate_attribute_values",
        "/layers/{layer_name}/values/{field_name}",
        request_method="GET",
        pregenerator=C2CPregenerator(),
    )
    # there's no view corresponding to that route, it is to be used from
    # mako templates to get the root of the "layers" web service
    config.add_route("layers_root", "/layers/", request_method="HEAD")

    # Resource proxy (load external url, useful when loading non https content)
    config.add_route("resourceproxy", "/resourceproxy", request_method="GET")

    # pyramid_formalchemy's configuration
    config.include("pyramid_formalchemy")
    config.include("fa.jquery")

    # define the srid, schema and parentschema
    # as global variables to be usable in the model
    c2cgeoportal.srid = settings["srid"]
    c2cgeoportal.schema = settings["schema"]
    c2cgeoportal.parentschema = settings["parentschema"]
    c2cgeoportal.formalchemy_default_zoom = get_setting(
        settings,
        ("admin_interface", "map_zoom"),
        c2cgeoportal.formalchemy_default_zoom
    )
    c2cgeoportal.formalchemy_default_x = get_setting(
        settings,
        ("admin_interface", "map_x"),
        c2cgeoportal.formalchemy_default_x
    )
    c2cgeoportal.formalchemy_default_y = get_setting(
        settings,
        ("admin_interface", "map_y"),
        c2cgeoportal.formalchemy_default_y
    )
    c2cgeoportal.formalchemy_available_functionalities = get_setting(
        settings,
        ("admin_interface", "available_functionalities"),
        c2cgeoportal.formalchemy_available_functionalities
    )
    c2cgeoportal.formalchemy_available_metadata = get_setting(
        settings,
        ("admin_interface", "available_metadata"),
        c2cgeoportal.formalchemy_available_metadata
    )
    c2cgeoportal.formalchemy_available_metadata = [
        e if isinstance(e, basestring) else e.get("name")
        for e in c2cgeoportal.formalchemy_available_metadata
    ]

    config.add_route("checker_all", "/checker_all", request_method="GET")

    config.add_route("version_json", "/version.json", request_method="GET")

    stats.init(config)

    # scan view decorator for adding routes
    config.scan(ignore=["c2cgeoportal.tests", "c2cgeoportal.scripts"])

    if "subdomains" in settings:  # pragma: no cover
        config.registry.registerUtility(
            MultiDomainStaticURLInfo(), IStaticURLInfo)

    # add the static view (for static resources)
    _add_static_view(config, "static", "c2cgeoportal:static")
    _add_static_view(config, "project", "c2cgeoportal:project")

    add_admin_interface(config)
    add_static_view(config)

    # Handles the other HTTP errors raised by the views. Without that,
    # the client receives a status=200 without content.
    config.add_view(error_handler, context=HTTPException)

    _log_versions(settings)
コード例 #11
0
ファイル: __init__.py プロジェクト: DavMerca007/c2cgeoportal
def includeme(config):
    """ This function returns a Pyramid WSGI application.
    """

    # update the settings object from the YAML application config file
    settings = config.get_settings()
    settings.update(yaml.load(file(settings.get("app.cfg"))))

    global srid
    global schema
    global parentschema
    global formalchemy_language
    global formalchemy_default_zoom
    global formalchemy_default_x
    global formalchemy_default_y
    global formalchemy_available_functionalities
    global formalchemy_available_metadata

    config.set_request_property(get_user_from_request, name="user")

    # configure 'locale' dir as the translation dir for c2cgeoportal app
    config.add_translation_dirs("c2cgeoportal:locale/")

    # initialize database
    engine = sqlalchemy.engine_from_config(settings, "sqlalchemy.")
    sqlahelper.add_engine(engine)
    config.include(pyramid_tm.includeme)
    config.include("pyramid_closure")

    # initialize the dbreflection module
    dbreflection.init(engine)

    # dogpile.cache configuration
    caching.init_region(settings["cache"])
    caching.invalidate_region()

    # bind the mako renderer to other file extensions
    add_mako_renderer(config, ".html")
    add_mako_renderer(config, ".js")
    config.include("pyramid_chameleon")

    # add the "geojson" renderer
    config.add_renderer("geojson", GeoJSON())

    # add decimal json renderer
    config.add_renderer("decimaljson", DecimalJSON())

    # add the "xsd" renderer
    config.add_renderer("xsd", XSD(sequence_callback=dbreflection._xsd_sequence_callback))

    # add the set_user_validator directive, and set a default user
    # validator
    config.add_directive("set_user_validator", set_user_validator)
    config.set_user_validator(default_user_validator)

    if settings.get("ogcproxy_enable", True):
        # add an OGCProxy view
        config.add_route("ogcproxy", "/ogcproxy", custom_predicates=(ogcproxy_route_predicate,))
        config.add_view("papyrus_ogcproxy.views:ogcproxy", route_name="ogcproxy")

    # add routes to the mapserver proxy
    config.add_route(
        "mapserverproxy",
        "/mapserv_proxy",
        custom_predicates=(mapserverproxy_route_predicate,),
        pregenerator=C2CPregenerator(role=True),
    )

    # add route to the tinyows proxy
    config.add_route("tinyowsproxy", "/tinyows_proxy", pregenerator=C2CPregenerator(role=True))

    # add routes to csv view
    config.add_route("csvecho", "/csv", request_method="POST")

    # add routes to the echo service
    config.add_route("echo", "/echo", request_method="POST")

    # add routes to the entry view class
    config.add_route("loginform", "/login.html", request_method="GET")
    config.add_route("login", "/login", request_method=("GET", "POST"))
    config.add_route("logout", "/logout", request_method="GET")
    config.add_route("loginchange", "/loginchange", request_method="POST")
    config.add_route("loginresetpassword", "/loginresetpassword", request_method="GET")
    config.add_route("testi18n", "/testi18n.html", request_method="GET")
    config.add_route("apijs", "/api.js", request_method="GET")
    config.add_route("xapijs", "/xapi.js", request_method="GET")
    config.add_route("apihelp", "/apihelp.html", request_method="GET")
    config.add_route("xapihelp", "/xapihelp.html", request_method="GET")
    config.add_route("themes", "/themes", request_method="GET", pregenerator=C2CPregenerator(role=True))
    config.add_route("invalidate", "/invalidate", request_method="GET")

    # checker routes, Checkers are web services to test and assess that
    # the application is correctly functioning.
    # These web services are used by tools like (nagios).
    config.add_route("checker_main", "/checker_main", request_method="GET")
    config.add_route("checker_viewer", "/checker_viewer", request_method="GET")
    config.add_route("checker_edit", "/checker_edit", request_method="GET")
    config.add_route("checker_edit_js", "/checker_edit_js", request_method="GET")
    config.add_route("checker_api", "/checker_api", request_method="GET")
    config.add_route("checker_xapi", "/checker_xapi", request_method="GET")
    config.add_route("checker_lang_files", "/checker_lang_files", request_method="GET")
    config.add_route("checker_printcapabilities", "/checker_printcapabilities", request_method="GET")
    config.add_route("checker_pdf", "/checker_pdf", request_method="GET")
    config.add_route("checker_print3capabilities", "/checker_print3capabilities", request_method="GET")
    config.add_route("checker_pdf3", "/checker_pdf3", request_method="GET")
    config.add_route("checker_fts", "/checker_fts", request_method="GET")
    config.add_route("checker_wmscapabilities", "/checker_wmscapabilities", request_method="GET")
    config.add_route("checker_wfscapabilities", "/checker_wfscapabilities", request_method="GET")
    config.add_route("checker_theme_errors", "/checker_theme_errors", request_method="GET")
    # collector
    config.add_route("check_collector", "/check_collector", request_method="GET")

    # print proxy routes
    config.add_route("printproxy", "/printproxy", request_method="HEAD")
    config.add_route(
        "printproxy_info", "/printproxy/info.json", request_method="GET", pregenerator=C2CPregenerator(role=True)
    )
    config.add_route("printproxy_create", "/printproxy/create.json", request_method="POST")
    config.add_route("printproxy_get", "/printproxy/{file}.printout", request_method="GET")
    # V3
    config.add_route(
        "printproxy_capabilities",
        "/printproxy/capabilities.json",
        request_method=("GET", "OPTIONS"),
        pregenerator=C2CPregenerator(role=True),
    )
    config.add_route("printproxy_report_create", "/printproxy/report.{format}", request_method=("POST", "OPTIONS"))
    config.add_route("printproxy_status", "/printproxy/status/{ref}.json", request_method=("GET", "OPTIONS"))
    config.add_route("printproxy_cancel", "/printproxy/cancel/{ref}", request_method=("DELETE", "OPTIONS"))
    config.add_route("printproxy_report_get", "/printproxy/report/{ref}", request_method="GET")

    # full text search routes
    config.add_route("fulltextsearch", "/fulltextsearch")

    # Access to raster data
    config.add_route("raster", "/raster", request_method="GET")
    config.add_route("profile.csv", "/profile.csv", request_method="POST")
    config.add_route("profile.json", "/profile.json", request_method="POST")

    # shortener
    config.add_route("shortener_create", "/short/create", request_method="POST")
    config.add_route("shortener_get", "/short/{ref}", request_method="GET")

    # Geometry processing
    config.add_route("difference", "/difference", request_method="POST")

    # PDF report tool
    config.add_route("pdfreport", "/pdfreport/{layername}/{id}", request_method="GET")

    # add routes for the "layers" web service
    config.add_route("layers_count", "/layers/{layer_id:\\d+}/count", request_method="GET")
    config.add_route(
        "layers_metadata",
        "/layers/{layer_id:\\d+}/md.xsd",
        request_method="GET",
        pregenerator=C2CPregenerator(role=True),
    )
    config.add_route(
        "layers_read_many", "/layers/{layer_id:\\d+,?(\\d+,)*\\d*$}", request_method="GET"
    )  # supports URLs like /layers/1,2,3
    config.add_route("layers_read_one", "/layers/{layer_id:\\d+}/{feature_id}", request_method="GET")
    config.add_route("layers_create", "/layers/{layer_id:\\d+}", request_method="POST")
    config.add_route("layers_update", "/layers/{layer_id:\\d+}/{feature_id}", request_method="PUT")
    config.add_route("layers_delete", "/layers/{layer_id:\\d+}/{feature_id}", request_method="DELETE")
    config.add_route(
        "layers_enumerate_attribute_values",
        "/layers/{layer_name}/values/{field_name}",
        request_method="GET",
        pregenerator=C2CPregenerator(),
    )
    # there's no view corresponding to that route, it is to be used from
    # mako templates to get the root of the "layers" web service
    config.add_route("layers_root", "/layers/", request_method="HEAD")

    # pyramid_formalchemy's configuration
    config.include("pyramid_formalchemy")
    config.include("fa.jquery")

    # define the srid, schema and parentschema
    # as global variables to be usable in the model
    srid = settings["srid"]
    schema = settings["schema"]
    parentschema = settings["parentschema"]
    formalchemy_default_zoom = get_setting(settings, ("admin_interface", "map_zoom"), formalchemy_default_zoom)
    formalchemy_default_x = get_setting(settings, ("admin_interface", "map_x"), formalchemy_default_x)
    formalchemy_default_y = get_setting(settings, ("admin_interface", "map_y"), formalchemy_default_y)
    formalchemy_available_functionalities = get_setting(
        settings, ("admin_interface", "available_functionalities"), formalchemy_available_functionalities
    )
    formalchemy_available_metadata = get_setting(
        settings, ("admin_interface", "available_metadata"), formalchemy_available_metadata
    )

    config.add_route("checker_all", "/checker_all", request_method="GET")

    # scan view decorator for adding routes
    config.scan(ignore="c2cgeoportal.tests")

    config.registry.registerUtility(MultiDomainStaticURLInfo(), IStaticURLInfo)

    # add the static view (for static resources)
    _add_static_view(config, "static", "c2cgeoportal:static")
    _add_static_view(config, "project", "c2cgeoportal:project")

    add_admin_interface(config)
    add_static_view(config)
コード例 #12
0
def includeme(config):
    """ This function returns a Pyramid WSGI application.
    """

    # update the settings object from the YAML application config file
    settings = config.get_settings()
    settings.update(yaml.load(file(settings.get("app.cfg"))))

    global srid
    global schema
    global parentschema
    global formalchemy_language
    global formalchemy_default_zoom
    global formalchemy_default_x
    global formalchemy_default_y
    global formalchemy_available_functionalities
    global formalchemy_available_metadata

    config.add_request_method(_create_get_user_from_request(settings),
                              name="user",
                              property=True)

    # configure 'locale' dir as the translation dir for c2cgeoportal app
    config.add_translation_dirs("c2cgeoportal:locale/")

    # initialize database
    engine = sqlalchemy.engine_from_config(settings, "sqlalchemy.")
    sqlahelper.add_engine(engine)
    config.include(pyramid_tm.includeme)
    config.include("pyramid_closure")

    # initialize the dbreflection module
    dbreflection.init(engine)

    # dogpile.cache configuration
    caching.init_region(settings["cache"])
    caching.invalidate_region()

    # bind the mako renderer to other file extensions
    add_mako_renderer(config, ".html")
    add_mako_renderer(config, ".js")
    config.include("pyramid_chameleon")

    # add the "geojson" renderer
    config.add_renderer("geojson", GeoJSON())

    # add decimal json renderer
    config.add_renderer("decimaljson", DecimalJSON())

    # add the "xsd" renderer
    config.add_renderer(
        "xsd", XSD(sequence_callback=dbreflection._xsd_sequence_callback))

    # add the set_user_validator directive, and set a default user
    # validator
    config.add_directive("set_user_validator", set_user_validator)
    config.set_user_validator(default_user_validator)

    if settings.get("ogcproxy_enable", True):
        # add an OGCProxy view
        config.add_route("ogcproxy",
                         "/ogcproxy",
                         custom_predicates=(ogcproxy_route_predicate, ))
        config.add_view("papyrus_ogcproxy.views:ogcproxy",
                        route_name="ogcproxy")

    # add routes to the mapserver proxy
    config.add_route(
        "mapserverproxy",
        "/mapserv_proxy",
        custom_predicates=(mapserverproxy_route_predicate, ),
        pregenerator=C2CPregenerator(role=True),
    )

    # add route to the tinyows proxy
    config.add_route(
        "tinyowsproxy",
        "/tinyows_proxy",
        pregenerator=C2CPregenerator(role=True),
    )

    # add routes to csv view
    config.add_route("csvecho", "/csv", request_method="POST")

    # add route to the export GPX/KML view
    config.add_route("exportgpxkml", "/exportgpxkml")

    # add routes to the echo service
    config.add_route("echo", "/echo", request_method="POST")

    # add routes to the entry view class
    config.add_route("loginform", "/login.html", request_method="GET")
    add_cors_route(config, "/login", "login")
    config.add_route("login", "/login", request_method=("GET", "POST"))
    add_cors_route(config, "/logout", "login")
    config.add_route("logout", "/logout", request_method="GET")
    add_cors_route(config, "/loginchange", "login")
    config.add_route("loginchange", "/loginchange", request_method="POST")
    add_cors_route(config, "/loginresetpassword", "login")
    config.add_route("loginresetpassword",
                     "/loginresetpassword",
                     request_method="GET")
    config.add_route("testi18n", "/testi18n.html", request_method="GET")
    config.add_route("apijs", "/api.js", request_method="GET")
    config.add_route("xapijs", "/xapi.js", request_method="GET")
    config.add_route("apihelp", "/apihelp.html", request_method="GET")
    config.add_route("xapihelp", "/xapihelp.html", request_method="GET")
    config.add_route(
        "themes",
        "/themes",
        request_method="GET",
        pregenerator=C2CPregenerator(role=True),
    )
    config.add_route("invalidate", "/invalidate", request_method="GET")

    # checker routes, Checkers are web services to test and assess that
    # the application is correctly functioning.
    # These web services are used by tools like (nagios).
    config.add_route("checker_main", "/checker_main", request_method="GET")
    config.add_route("checker_viewer", "/checker_viewer", request_method="GET")
    config.add_route("checker_edit", "/checker_edit", request_method="GET")
    config.add_route("checker_edit_js",
                     "/checker_edit_js",
                     request_method="GET")
    config.add_route("checker_api", "/checker_api", request_method="GET")
    config.add_route("checker_xapi", "/checker_xapi", request_method="GET")
    config.add_route("checker_lang_files",
                     "/checker_lang_files",
                     request_method="GET")
    config.add_route(
        "checker_printcapabilities",
        "/checker_printcapabilities",
        request_method="GET",
    )
    config.add_route("checker_pdf", "/checker_pdf", request_method="GET")
    config.add_route(
        "checker_print3capabilities",
        "/checker_print3capabilities",
        request_method="GET",
    )
    config.add_route("checker_pdf3", "/checker_pdf3", request_method="GET")
    config.add_route("checker_fts", "/checker_fts", request_method="GET")
    config.add_route("checker_wmscapabilities",
                     "/checker_wmscapabilities",
                     request_method="GET")
    config.add_route("checker_wfscapabilities",
                     "/checker_wfscapabilities",
                     request_method="GET")
    config.add_route("checker_theme_errors",
                     "/checker_theme_errors",
                     request_method="GET")
    # collector
    config.add_route("check_collector",
                     "/check_collector",
                     request_method="GET")

    # print proxy routes
    config.add_route("printproxy", "/printproxy", request_method="HEAD")
    config.add_route(
        "printproxy_info",
        "/printproxy/info.json",
        request_method="GET",
        pregenerator=C2CPregenerator(role=True),
    )
    config.add_route(
        "printproxy_create",
        "/printproxy/create.json",
        request_method="POST",
    )
    config.add_route(
        "printproxy_get",
        "/printproxy/{file}.printout",
        request_method="GET",
    )
    # V3
    add_cors_route(config, "/printproxy/*all", "print")
    config.add_route(
        "printproxy_capabilities",
        "/printproxy/capabilities.json",
        request_method="GET",
        pregenerator=C2CPregenerator(role=True),
    )
    config.add_route("printproxy_report_create",
                     "/printproxy/report.{format}",
                     request_method="POST",
                     header=JSON_CONTENT_TYPE)
    config.add_route("printproxy_status",
                     "/printproxy/status/{ref}.json",
                     request_method="GET")
    config.add_route("printproxy_cancel",
                     "/printproxy/cancel/{ref}",
                     request_method="DELETE")
    config.add_route("printproxy_report_get",
                     "/printproxy/report/{ref}",
                     request_method="GET")

    # full text search routes
    add_cors_route(config, "/fulltextsearch", "fulltextsearch")
    config.add_route("fulltextsearch", "/fulltextsearch")

    # Access to raster data
    add_cors_route(config, "/raster", "raster")
    config.add_route("raster", "/raster", request_method="GET")

    add_cors_route(config, "/profile.{ext}", "profile")
    config.add_route("profile.csv", "/profile.csv", request_method="POST")
    config.add_route("profile.json", "/profile.json", request_method="POST")

    # shortener
    config.add_route("shortener_create",
                     "/short/create",
                     request_method="POST")
    config.add_route("shortener_get", "/short/{ref}", request_method="GET")

    # Geometry processing
    config.add_route("difference", "/difference", request_method="POST")

    # PDF report tool
    config.add_route("pdfreport",
                     "/pdfreport/{layername}/{id}",
                     request_method="GET")

    # add routes for the "layers" web service
    add_cors_route(config, "/layers/*all", "layers")
    config.add_route("layers_count",
                     "/layers/{layer_id:\\d+}/count",
                     request_method="GET")
    config.add_route(
        "layers_metadata",
        "/layers/{layer_id:\\d+}/md.xsd",
        request_method="GET",
        pregenerator=C2CPregenerator(role=True),
    )
    config.add_route("layers_read_many",
                     "/layers/{layer_id:\\d+,?(\\d+,)*\\d*$}",
                     request_method="GET")  # supports URLs like /layers/1,2,3
    config.add_route("layers_read_one",
                     "/layers/{layer_id:\\d+}/{feature_id}",
                     request_method="GET")
    config.add_route("layers_create",
                     "/layers/{layer_id:\\d+}",
                     request_method="POST",
                     header=JSON_CONTENT_TYPE)
    config.add_route("layers_update",
                     "/layers/{layer_id:\\d+}/{feature_id}",
                     request_method="PUT",
                     header=JSON_CONTENT_TYPE)
    config.add_route("layers_delete",
                     "/layers/{layer_id:\\d+}/{feature_id}",
                     request_method="DELETE")
    config.add_route(
        "layers_enumerate_attribute_values",
        "/layers/{layer_name}/values/{field_name}",
        request_method="GET",
        pregenerator=C2CPregenerator(),
    )
    # there's no view corresponding to that route, it is to be used from
    # mako templates to get the root of the "layers" web service
    config.add_route("layers_root", "/layers/", request_method="HEAD")

    # pyramid_formalchemy's configuration
    config.include("pyramid_formalchemy")
    config.include("fa.jquery")

    # define the srid, schema and parentschema
    # as global variables to be usable in the model
    srid = settings["srid"]
    schema = settings["schema"]
    parentschema = settings["parentschema"]
    formalchemy_default_zoom = get_setting(settings,
                                           ("admin_interface", "map_zoom"),
                                           formalchemy_default_zoom)
    formalchemy_default_x = get_setting(settings, ("admin_interface", "map_x"),
                                        formalchemy_default_x)
    formalchemy_default_y = get_setting(settings, ("admin_interface", "map_y"),
                                        formalchemy_default_y)
    formalchemy_available_functionalities = get_setting(
        settings, ("admin_interface", "available_functionalities"),
        formalchemy_available_functionalities)
    formalchemy_available_metadata = get_setting(
        settings, ("admin_interface", "available_metadata"),
        formalchemy_available_metadata)

    config.add_route("checker_all", "/checker_all", request_method="GET")

    # scan view decorator for adding routes
    config.scan(ignore="c2cgeoportal.tests")

    config.registry.registerUtility(MultiDomainStaticURLInfo(), IStaticURLInfo)

    # add the static view (for static resources)
    _add_static_view(config, "static", "c2cgeoportal:static")
    _add_static_view(config, "project", "c2cgeoportal:project")

    add_admin_interface(config)
    add_static_view(config)

    # Handles the other HTTP errors raised by the views. Without that,
    # the client receives a status=200 without content.
    config.add_view(error_handler, context=HTTPException)