plaster-pastedeploy Registry Entry
Plaster-pastedeploy provides a `plaster` loader that understands `PasteDeploy` configuration files, primarily used for loading WSGI applications and server configurations from INI-style files. It is currently at version 1.0.1. Its release cadence is generally stable and aligns with major `plaster` and `PasteDeploy` releases.
Warnings
- gotcha For plaster-pastedeploy's loader to be available to `plaster.parse_uri`, `import plaster_pastedeploy` must be executed *before* `plaster.parse_uri` is called. This ensures the entry points are loaded and the PasteDeploy loader is registered.
- gotcha PasteDeploy configurations often use `egg:package#factory` syntax for specifying applications and servers. These rely on `setuptools` entry points and the referenced packages being installed in your Python environment. If packages like `webtest-app` or `waitress` (common in examples) are not installed, `plaster-pastedeploy` will raise `DistributionNotFound` or similar errors during configuration loading.
- breaking `plaster-pastedeploy` v1.x is designed to work with `plaster` v1.x. `plaster` itself introduced significant breaking changes between its 0.x and 1.x versions (e.g., `plaster.PlasterLoader` was removed). Attempting to use `plaster-pastedeploy` 1.x with `plaster` 0.x, or an older `plaster-pastedeploy` with `plaster` 1.x, will lead to API incompatibilities and runtime errors.
Install
-
pip install plaster-pastedeploy
Imports
- plaster_pastedeploy
import plaster_pastedeploy
- parse_uri
from plaster import parse_uri
Quickstart
import os
import plaster
import plaster_pastedeploy # This registers the PasteDeploy loader
# Create a dummy PasteDeploy-style config file
config_content = """
[app:main]
use = egg:webtest_app#main
[server:main]
use = egg:waitress#main
host = 127.0.0.1
port = 8080
"""
config_path = "development.ini"
with open(config_path, "w") as f:
f.write(config_content)
# Parse the URI using plaster (which now knows about PasteDeploy thanks to plaster_pastedeploy)
# Note: webtest_app and waitress would need to be installed for a real application.
try:
loader = plaster.parse_uri(f"config:{config_path}")
print(f"Successfully parsed configuration using loader: {type(loader).__name__}")
# Example: Get a WSGI application
app = loader.get_wsgi_app("main")
print(f"WSGI App loaded: {app}")
# Example: Get a WSGI server factory
server_factory = loader.get_wsgi_server("main")
print(f"WSGI Server factory loaded: {server_factory}")
except Exception as e:
print(f"An error occurred: {e}")
finally:
# Clean up the dummy config file
if os.path.exists(config_path):
os.remove(config_path)