{"id":3213,"library":"plaster","title":"Plaster","description":"Plaster is a loader interface designed to abstract away multiple configuration file formats. It provides a common API for applications to load settings, supporting pluggable loaders discovered via entrypoints. The library focuses on providing a basic interface, leaving specific constraints and implementations to these pluggable loaders. The current version is 1.1.2, released in November 2022, and it is actively maintained by the Pylons Project.","status":"active","version":"1.1.2","language":"en","source_language":"en","source_url":"https://github.com/Pylons/plaster","tags":["configuration","config file","loader","Pylons","entrypoint","settings"],"install":[{"cmd":"pip install plaster","lang":"bash","label":"Install stable release"}],"dependencies":[{"reason":"Requires Python 3.7 or newer. Support for Python 2.7, 3.4, 3.5, and 3.6 was dropped in version 1.1.","package":"python","optional":false}],"imports":[{"note":"Used to load configuration settings from a URI and section.","symbol":"get_settings","correct":"from plaster import get_settings"},{"note":"Configures Python's standard logging module based on the provided configuration URI.","symbol":"setup_logging","correct":"from plaster import setup_logging"},{"note":"Finds and returns an ILoader object capable of handling a given configuration URI.","symbol":"get_loader","correct":"from plaster import get_loader"},{"note":"Parses a configuration URI into a PlasterURL object, which can then be used by loaders.","symbol":"parse_uri","correct":"from plaster import parse_uri"}],"quickstart":{"code":"import plaster\nimport sys\n\n# Example config_uri. In a real app, this might come from command line args or an environment variable.\n# For demonstration, we'll use a placeholder. Replace 'development.ini#myapp' with your actual config URI.\n# You might need a loader like 'plaster_pastedeploy' installed for .ini files.\nconfig_uri = 'development.ini#myapp'\n\ntry:\n    # Load settings for a specific section (e.g., 'myapp')\n    settings = plaster.get_settings(config_uri, section='myapp')\n    print(\"Loaded settings:\", settings)\n\n    # Optionally configure logging based on the config file\n    plaster.setup_logging(config_uri)\n    print(\"Logging configured.\")\n\n    # Example: Accessing a specific setting\n    if 'my_setting_key' in settings:\n        print(f\"Value of 'my_setting_key': {settings['my_setting_key']}\")\n    else:\n        print(\"No 'my_setting_key' found in settings.\")\n\nexcept plaster.LoaderNotFound:\n    print(f\"Error: No loader found for URI '{config_uri}'. Make sure the appropriate plaster plugin (e.g., plaster_pastedeploy) is installed.\")\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to load configuration settings from a URI and configure standard logging using `plaster.get_settings()` and `plaster.setup_logging()`. It shows how to specify a configuration file (like 'development.ini') and a specific section ('myapp') to retrieve settings. To run this, you would typically need a loader plugin (e.g., `pip install plaster_pastedeploy`) and a corresponding config file."},"warnings":[{"fix":"Upgrade Python to 3.7+ or pin `plaster<1.1`.","message":"Version 1.1 of Plaster dropped support for older Python versions (2.7, 3.4, 3.5, 3.6). Projects on these Python versions must either upgrade their Python environment or pin Plaster to a version older than 1.1.","severity":"breaking","affected_versions":"<1.1"},{"fix":"Review any custom entry point handling to ensure compatibility with `importlib.metadata`.","message":"In version 1.1, Plaster switched from `setuptools`/`pkg_resources` to `importlib.metadata` for entry point discovery. While this generally improves performance and reduces runtime dependencies, it might impact advanced use cases that directly interact with entry point mechanisms previously relying on `pkg_resources`.","severity":"breaking","affected_versions":">=1.1"},{"fix":"Disambiguate the lookup by appending the package name to the scheme in the `config_uri` (e.g., `ini+myapp://config.ini` to use the 'ini' loader from the 'myapp' package).","message":"`plaster.exceptions.MultipleLoadersFound` can be raised if multiple installed loaders match the criteria for a `config_uri`. This ambiguity prevents Plaster from choosing a specific loader.","severity":"gotcha","affected_versions":"All"},{"fix":"Upgrade to `plaster>=1.1.2` to receive a `LoaderNotFound` exception instead of an unhandled crash.","message":"Prior to version 1.1.2, if a `config_uri` specified a distribution that lacked the expected entry points, Plaster could crash unexpectedly due to a bad unpacking of tuples. This is now caught and raises a `LoaderNotFound` exception.","severity":"gotcha","affected_versions":"<1.1.2"},{"fix":"Ensure `config_uri`s are formatted according to current specifications, especially for older configurations. Explicitly use `package+scheme` for package-specific loaders.","message":"The `config_uri` parsing behavior for schemes changed in version 0.5. Schemes are now automatically generated as `file+<ext>` for file paths without an explicit scheme (e.g., `file+ini` instead of just `ini`). Also, the order for absolute lookups changed from `scheme+package` to `package+scheme`.","severity":"gotcha","affected_versions":"<0.5"},{"fix":"Install the appropriate `plaster` plugin for the configuration file format you intend to use (e.g., `pip install plaster_pastedeploy` for INI files).","message":"Plaster's core functionality relies on external 'loader' plugins (e.g., `plaster_pastedeploy`, `plaster_yaml`) to support specific configuration file formats. Without the relevant plugin installed for a given `config_uri` scheme, Plaster will not be able to load the configuration.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}