Registry / serialization / plaster

plaster

JSON →
library1.1.2pypypi✓ verified 24d ago

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.

pip install plaster
INSTALL
IMPORT
SIG · PLASTER
P
plaster
serializationpythonv1.1.2
Install
1.5s avg
Import
94ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.098s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.090s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

get_settings
from plaster import get_settings
Used to load configuration settings from a URI and section.
setup_logging
from plaster import setup_logging
Configures Python's standard logging module based on the provided configuration URI.
get_loader
from plaster import get_loader
Finds and returns an ILoader object capable of handling a given configuration URI.
parse_uri
from plaster import parse_uri
Parses a configuration URI into a PlasterURL object, which can then be used by loaders.

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.

import plaster import sys # Example config_uri. In a real app, this might come from command line args or an environment variable. # For demonstration, we'll use a placeholder. Replace 'development.ini#myapp' with your actual config URI. # You might need a loader like 'plaster_pastedeploy' installed for .ini files. config_uri = 'development.ini#myapp' try: # Load settings for a specific section (e.g., 'myapp') settings = plaster.get_settings(config_uri, section='myapp') print("Loaded settings:", settings) # Optionally configure logging based on the config file plaster.setup_logging(config_uri) print("Logging configured.") # Example: Accessing a specific setting if 'my_setting_key' in settings: print(f"Value of 'my_setting_key': {settings['my_setting_key']}") else: print("No 'my_setting_key' found in settings.") except plaster.LoaderNotFound: print(f"Error: No loader found for URI '{config_uri}'. Make sure the appropriate plaster plugin (e.g., plaster_pastedeploy) is installed.") except Exception as e: print(f"An error occurred: {e}")
Debug
Known issues
breakingVersion 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.
fix
Upgrade Python to 3.7+ or pin `plaster<1.1`.
affects: <1.1
breakingIn 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`.
fix
Review any custom entry point handling to ensure compatibility with `importlib.metadata`.
affects: >=1.1
gotcha`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.
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).
affects: All
gotchaPrior 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.
fix
Upgrade to `plaster>=1.1.2` to receive a `LoaderNotFound` exception instead of an unhandled crash.
affects: <1.1.2
gotchaThe `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`.
fix
Ensure `config_uri`s are formatted according to current specifications, especially for older configurations. Explicitly use `package+scheme` for package-specific loaders.
affects: <0.5
gotchaPlaster'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.
fix
Install the appropriate `plaster` plugin for the configuration file format you intend to use (e.g., `pip install plaster_pastedeploy` for INI files).
affects: All
Errors
Common errors & fixes
plaster.exceptions.LoaderNotFound: Could not find a matching loader for the scheme "file+ini", protocol "wsgi"
This error occurs when `plaster` cannot find an installed loader that supports the requested scheme (e.g., 'file+ini') and protocol (e.g., 'wsgi') specified in the configuration URI. This usually means the necessary plugin for that configuration format is not installed.
fix
Install the appropriate `plaster` loader plugin for your configuration format, such as `plaster_pastedeploy` for INI files with WSGI applications: `pip install plaster_pastedeploy`
plaster.exceptions.InvalidURI: Unable to parse config_uri "{uri}"
This exception is raised when `plaster.parse_uri()` fails to interpret the provided `config_uri` string, indicating an incorrectly formatted or malformed URI.
fix
Ensure the `config_uri` adheres to `plaster`'s expected format, which typically includes a scheme (e.g., `ini://`, `file://`), a path, and optionally a fragment or query parameters (e.g., `development.ini#myapp`, `pastedeploy+ini:///path/to/development.ini`). Double-check for typos or missing components.
plaster.exceptions.MultipleLoadersFound: Multiple plaster loaders were found for {scheme}. Please specify a more specific config_uri. Matched loaders: {loaders}
This error occurs when `plaster` finds more than one loader capable of handling the specified `scheme` and cannot unambiguously determine which one to use.
fix
To resolve the ambiguity, append the package name of the desired loader to the scheme in your `config_uri`. For example, if 'ini' is ambiguous, specify `ini+myapp` to use the 'ini' loader from the 'myapp' package.
ModuleNotFoundError: No module named 'plaster_pastedeploy'
This indicates that a specific `plaster`-compatible loader, such as `plaster_pastedeploy`, is imported or expected but has not been installed in your Python environment. `plaster` relies on separate packages for different configuration formats.
fix
Install the missing loader package using pip: `pip install plaster_pastedeploy`. Replace `plaster_pastedeploy` with the correct package name if a different loader is missing.
LookupError: If a WSGI application cannot be found by the specified name.
This `LookupError` is raised by `plaster`'s WSGI-related functions (e.g., `get_wsgi_app`, `get_wsgi_app_settings`, `get_wsgi_filter`, `get_wsgi_server`) when an application, filter, or server with the specified name cannot be located within the loaded configuration.
fix
Ensure that the `name` parameter passed to the `get_wsgi_` function correctly matches a defined WSGI component in your configuration file (e.g., a section name in an INI file). If `name` is `None`, verify that a default can be derived from the `PlasterURL.fragment` if applicable.
Upgrade
Version history
1.1.2latest on PyPI · released Nov 21, 2022
Audit
Dependencies
pythonrequiredRequires Python 3.7 or newer. Support for Python 2.7, 3.4, 3.5, and 3.6 was dropped in version 1.1.
Agent activity
5 hits · last 30 days
node
4
Resources