Python pyramid.settings.aslist() Examples

The following are 7 code examples of pyramid.settings.aslist(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pyramid.settings , or try the search function .
Example #1
Source File: tween.py    From pyramid_swagger with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def load_settings(registry):
    return Settings(
        swagger12_handler=build_swagger12_handler(
            registry.settings.get('pyramid_swagger.schema12')),
        swagger20_handler=build_swagger20_handler(),
        validate_request=asbool(registry.settings.get(
            'pyramid_swagger.enable_request_validation',
            True,
        )),
        validate_response=asbool(registry.settings.get(
            'pyramid_swagger.enable_response_validation',
            True,
        )),
        validate_path=asbool(registry.settings.get(
            'pyramid_swagger.enable_path_validation',
            True,
        )),
        exclude_paths=get_exclude_paths(registry),
        exclude_routes=set(aslist(registry.settings.get(
            'pyramid_swagger.exclude_routes',
        ) or [])),
        prefer_20_routes=set(aslist(registry.settings.get(
            'pyramid_swagger.prefer_20_routes') or [])),
    ) 
Example #2
Source File: tween.py    From pyramid_swagger with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def get_swagger_versions(settings):
    """
    Validates and returns the versions of the Swagger Spec that this pyramid
    application supports.

    :type settings: dict
    :return: list of strings. eg ['1.2', '2.0']
    :raises: ValueError when an unsupported Swagger version is encountered.
    """
    swagger_versions = set(aslist(settings.get(
        'pyramid_swagger.swagger_versions', DEFAULT_SWAGGER_VERSIONS)))

    if len(swagger_versions) == 0:
        raise ValueError('pyramid_swagger.swagger_versions is empty')

    for swagger_version in swagger_versions:
        if swagger_version not in SUPPORTED_SWAGGER_VERSIONS:
            raise ValueError('Swagger version {0} is not supported.'
                             .format(swagger_version))
    return swagger_versions 
Example #3
Source File: __init__.py    From opentelemetry-python with Apache License 2.0 6 votes vote down vote up
def _traced_init(wrapped, instance, args, kwargs):
    settings = kwargs.get("settings", {})
    tweens = aslist(settings.get("pyramid.tweens", []))

    if tweens and TWEEN_NAME not in settings:
        # pyramid.tweens.EXCVIEW is the name of built-in exception view provided by
        # pyramid.  We need our tween to be before it, otherwise unhandled
        # exceptions will be caught before they reach our tween.
        tweens = [TWEEN_NAME] + tweens

        settings["pyramid.tweens"] = "\n".join(tweens)

    kwargs["settings"] = settings

    # `caller_package` works by walking a fixed amount of frames up the stack
    # to find the calling package. So if we let the original `__init__`
    # function call it, our wrapper will mess things up.
    if not kwargs.get("package", None):
        # Get the package for the third frame up from this one.
        # Default is `level=2` which will give us the package from `wrapt`
        # instead of the desired package (the caller)
        kwargs["package"] = caller_package(level=3)

    wrapped(*args, **kwargs)
    instance.include("opentelemetry.ext.pyramid.callbacks") 
Example #4
Source File: engine.py    From nefertari with Apache License 2.0 5 votes vote down vote up
def includeme(config):
    engine_paths = aslist(config.registry.settings['nefertari.engine'])
    for path in engine_paths:
        config.include(path)
    _load_engines(config)
    main_engine_module = engines[0]
    _import_public_names(main_engine_module)


# replaced by registered engine modules during configuration 
Example #5
Source File: engine.py    From nefertari with Apache License 2.0 5 votes vote down vote up
def _load_engines(config):
    global engines
    engine_paths = aslist(config.registry.settings['nefertari.engine'])
    engines = tuple([resolve(path) for path in engine_paths]) 
Example #6
Source File: common_utils.py    From travelcrm with GNU General Public License v3.0 5 votes vote down vote up
def get_available_locales():
    settings = get_settings()
    return aslist(settings.get('pyramid.available_languages')) 
Example #7
Source File: models.py    From pyvac with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def includeme(config):
    """
    Pyramid includeme file for the :class:`pyramid.config.Configurator`
    """

    settings = config.registry.settings

    if 'pyvac.vacation.cp_class.enable' in settings:
        cp_class = asbool(settings['pyvac.vacation.cp_class.enable'])
        if cp_class:
            if 'pyvac.vacation.cp_class.base_file' in settings:
                file = settings['pyvac.vacation.cp_class.base_file']
                CPVacation.initialize(file)

    if 'pyvac.vacation.extra_cp.enable' in settings:
        extra_cp = asbool(settings['pyvac.vacation.extra_cp.enable'])
        if extra_cp:
            CPVacation.extra_cp = True
            if 'pyvac.vacation.extra_cp.cycle_end_year' in settings:
                CPVacation.cycle_end_year = int(settings['pyvac.vacation.extra_cp.cycle_end_year']) # noqa
            if 'pyvac.vacation.extra_cp.cycle_start' in settings:
                date = settings['pyvac.vacation.extra_cp.cycle_start']
                CPVacation.cycle_start = datetime.strptime(date, '%d/%m/%Y')
            if 'pyvac.vacation.extra_cp.delta_restant' in settings:
                CPVacation.delta_restant = int(settings['pyvac.vacation.extra_cp.delta_restant']) # noqa

    if 'pyvac.vacation.cp_lu_class.enable' in settings:
        cp_lu_class = asbool(settings['pyvac.vacation.cp_lu_class.enable'])
        if cp_lu_class:
            if 'pyvac.vacation.cp_lu_class.base_file' in settings:
                file = settings['pyvac.vacation.cp_lu_class.base_file']
                CPLUVacation.initialize(file)

    if 'pyvac.vacation.rtt_class.enable' in settings:
        rtt_class = asbool(settings['pyvac.vacation.rtt_class.enable'])
        if rtt_class:
            if 'pyvac.vacation.rtt_class.except_months' in settings:
                except_months = settings['pyvac.vacation.rtt_class.except_months'] # noqa
                RTTVacation.initialize(aslist(except_months))

    if 'pyvac.firm' in settings:
        User.firm = settings['pyvac.firm']

    if 'pyvac.features.users_flagfile' in settings:
        User.users_flagfile = settings['pyvac.features.users_flagfile']
        User.load_feature_flags()

    if 'pyvac.password.sender.mail' in settings:
        Request.sender_mail = settings['pyvac.password.sender.mail']