Skip to main content

plaster-yaml

Configure your applications with YAML (and JSON) structured data.

CI codecov

Introduction

The plaster-yaml plugin lets applications, notably Pyramid applications but also other applications that use the plaster loader interface, accept YAML configuration sources.

By default, Pyramid (etc.) uses the PasteDeploy (.ini) file format for its configuration. PasteDeploy has become obsolete and has been replace by plaster and accept plugins to write more file format.

With the plaster-yaml plugin, Pyramid applications can also be configured with a YAML configuration file.

For example, one application can be run either of these ways:

Because JSON is a subset of YAML plaster-yaml also supports JSON configuration files. The "With pyproject.toml and a setuptools build back-end" section below contains a JSON example.

pserve development.yaml
pserve development.json
pserve development.ini

Installation

With poetry

poetry add plaster-yaml

With pip

pip install plaster-yaml

Usage

WSGI application that use plaster have to register an entry point, from a paste.app_factory.

With poetry

App registration is configured in your pyproject.toml, as follows:

[tool.poetry.plugins."paste.app_factory"]
main = "<PATH_TO_MODULE_CONTAINING_MAIN>:main"

When developing, run poetry install to register your application after adding the above to your pyproject.toml.

With setuptools

When developing, run pip install -e . to register your application after using either of approaches below.

With pyproject.toml and a setuptools build back-end

This is the preferred method.

Plugin registration may be configured in your pyproject.toml, as follows:

[project.entry-points.'paste.app_factory']
main = '<my_app>:main']

Adding a final line to the example lets the application support JSON in additional to YAML and .ini config files:

[project.entry-points.'paste.app_factory']
main = '<my_app>:main']

With setup.py

This method is generally obsolete, but it can be used when the [project.entry-points] table is declared "dynamic". However, this method must be used when the deprecated python setup.py ... command is the package building method.

Application registration may be configured in your setup.py, as follows:

setup(
    ...,
    entry_points={
     'paste.app_factory': ['main = <my_app>:main'],
     ...
    },
)

Appendix: A sample YAML config file for Pyramid

The sample YAML config file shown here configures the MYAPP Pyramid application. The YAML mapping of the app key is presented to the Pyramid application as a Python dictionary. (Excepting the "use" key, which is where the system is told that the "MYAPP" python package is the one to use.)

Within your view callable code, the code which processes a web request and produces a response for rendering, the "my_config_data" configuration value is available via request.registry.settings["my_config_data"]. That is, if the usual coding idiom is used and your view is defined with def myview(request):.

Likewise, the settings dict is available to your configuration code as settings. Again, assuming the usual coding idiom of def main(global_config, **settings): is used in your __init__.py. The global_config variable is then a dict containing the content of the config file's top-level DEFAULT key, if any.

For more information see: the Pyramid Startup documentation

###
# app configuration
# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html
###

app:
  "use": "egg:MYAPP"

  "pyramid.reload_templates": false
  "pyramid.debug_authorization": false
  "pyramid.debug_notfound": false
  "pyramid.debug_routematch": false
  "pyramid.default_locale_name": en
  "pyramid.includes": []

  "my_config_data": "Fe Fi Fo Fum"

DEFAULT:
  some_data_which_assists_app_startup: {automatic: false}

server:
  use: egg:waitress#main
  host: 0.0.0.0
  port: 6543

logging:
  version: 1
  disable_existing_loggers: false
  formatters:
    console:
      format: '%(asctime)s [%(levelname)s]: %(name)s - %(message)s'
  handlers:
    console:
      class: logging.StreamHandler
      level: INFO
      stream: ext://sys.stdout
      formatter: console
  root:
    level: INFO
    handlers:
      - console
  loggers:
    dummy:
      level: DEBUG

Metadata

Release files for plaster-yaml 3.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for plaster-yaml 3.1.0
File Size Uploaded Provenance Actions
plaster_yaml-3.1.0.tar.gz 6.7 kB Without provenance Details for plaster_yaml-3.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for plaster-yaml 3.1.0
File Interpreter ABI Platform Actions
plaster_yaml-3.1.0-py3-none-any.whl Python 3 none any Details for plaster_yaml-3.1.0-py3-none-any.whl

Total release size: 14.3 kB

Release files / plaster_yaml-3.1.0.tar.gz

Download URL plaster_yaml-3.1.0.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8e5250c12519c9e347cc1f7be4e2182ffb3418ae33ae543dd6874edeb4776420
BLAKE2b-256 checksum
How to use checksums
7edf01a370e8fc83de48fb66002b801bc8e2f077ac70bd0f9bca8dd51e04fbc0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via pdm/2.29.7 CPython/3.12.16 Linux/7.0.0-1017-azure

Release files / plaster_yaml-3.1.0-py3-none-any.whl

Download URL plaster_yaml-3.1.0-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8144a7add08724317a1518e984b2ed7379eb19ba00fcdce18c67658f5c46c62c
BLAKE2b-256 checksum
How to use checksums
0278d829fd21de1aa407400e9ad4e29928c00c433ef87a733bc0d82a15622a45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via pdm/2.29.7 CPython/3.12.16 Linux/7.0.0-1017-azure

Security for plaster-yaml 3.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page