コード例 #1
0
 def __init__(self):
     super().__init__()
     if os.path.exists("geoportal/config.yaml"):
         config.init("geoportal/config.yaml")
         self.config = config.get_config()
     else:
         self.config = None
     self.tpl = None
コード例 #2
0
def settings():
    config_uri = 'tests.ini' if os.path.exists(
        'tests.ini') else 'commons/tests.ini'
    fileConfig(config_uri, defaults=dict(os.environ))
    settings = plaster.get_settings(config_uri, 'tests')
    config.init(settings.get('app.cfg'))
    settings.update(config.get_config())
    return settings
コード例 #3
0
def includeme(config: Configurator) -> None:
    """
    Initialize the model for a Pyramid app.
    Activate this setup using ``config.include('c2cgeoportal_admin.commons')``.
    """
    settings = config.get_settings()

    configuration.init(settings.get('app.cfg'))
    # update the settings object from the YAML application config file
    settings.update(configuration.get_config())
コード例 #4
0
ファイル: env.py プロジェクト: geoATbsPUNKTch/c2cgeoportal
def get_config():
    config.init(context.config.get_main_option('app.cfg'))
    settings = {}
    settings.update(config.get_config())
    main = context.config.get_main_option('type') == 'main'
    settings.update({
        'script_location': context.config.get_main_option('script_location'),
        'version_table': context.config.get_main_option('version_table'),
        'version_locations': context.config.get_main_option('version_locations'),
        'version_table_schema': config['schema' if main else 'schema_static'],
    })
    return settings
コード例 #5
0
 def __init__(self):
     super().__init__()
     if os.path.exists("geoportal/config.yaml"):
         config.init("geoportal/config.yaml")
         self.config = config.get_config()
     else:
         self.config = None
     if os.path.exists("project.yaml"):
         with open("project.yaml") as f:
             self.package = yaml.safe_load(f)
     else:
         self.package = None
     self.env = None
コード例 #6
0
 def __init__(self):
     super().__init__()
     log.info(f'entering into {self.__class__} lux extractor')
     if os.path.exists("geoportal/config.yaml"):
         config.init("geoportal/config.yaml")
         self.config = config.get_config()
     else:
         self.config = None
     if os.path.exists("project.yaml"):
         with open("project.yaml") as f:
             self.package = yaml.safe_load(f)
     else:
         self.package = None
     self.env = None
     self.messages = []
     self.fields = set()
     self.TIMEOUT = 15
コード例 #7
0
    def _collect_app_config(self, filename):
        config.init(filename)
        settings = config.get_config()
        # Collect raster layers names
        raster = [
            Message(None, raster_layer, None, [], "", "",
                    (filename, "raster/{}".format(raster_layer)))
            for raster_layer in list(settings.get("raster", {}).keys())
        ]

        # Collect layers enum values (for filters)

        class R:
            settings = None

        class C:
            registry = R()

        config_ = C()
        config_.registry.settings = settings
        init_dbsessions(settings, config_)
        from c2cgeoportal_commons import models
        c2cgeoportal_geoportal.init_dbsessions(settings, config_)
        from c2cgeoportal_geoportal.views.layers import Layers
        enums = []
        enum_layers = settings.get("layers", {}).get("enum", {})
        for layername in list(enum_layers.keys()):
            layerinfos = enum_layers.get(layername, {})
            attributes = layerinfos.get("attributes", {})
            for fieldname in list(attributes.keys()):
                values = self._enumerate_attributes_values(
                    models.DBSessions, Layers, layerinfos, fieldname)
                for value, in values:
                    if value != "":
                        msgid = value if isinstance(value, str) else value
                        location = "/layers/{}/values/{}/{}".format(
                            layername, fieldname,
                            value.encode("ascii", errors="replace")
                            if isinstance(value, str) else value)
                        enums.append(
                            Message(None, msgid, None, [], "", "",
                                    (filename, location)))

        return raster + enums
コード例 #8
0
def main(_, **settings):
    """
    This function returns a Pyramid WSGI application.
    """
    configuration.init(settings.get('app.cfg'))
    settings.update(configuration.get_config())

    config = Configurator(settings=settings)
    config.include('c2cwsgiutils.pyramid.includeme')

    config.include('c2cgeoportal_admin')

    from c2cgeoportal_commons.testing import (
        generate_mappers,
        get_engine,
        get_session_factory,
        get_tm_session,
    )

    # Initialize the dev dbsession
    settings = config.get_settings()
    settings['tm.manager_hook'] = 'pyramid_tm.explicit_manager'

    session_factory = get_session_factory(get_engine(settings))
    config.registry['dbsession_factory'] = session_factory

    # Make request.dbsession available for use in Pyramid
    config.add_request_method(
        # request.tm is the transaction manager used by pyramid_tm
        lambda request: get_tm_session(session_factory, request.tm),
        'dbsession',
        reify=True)

    config.add_subscriber(add_renderer_globals, BeforeRender)
    config.add_subscriber(add_localizer, NewRequest)

    generate_mappers()

    health_check = HealthCheck(config)
    health_check.add_url_check('http://{}/'.format(
        settings['healthcheck_host']))

    return config.make_wsgi_app()