plaster-pastedeploy Registry Entry

1.0.1 · active · verified Sat Apr 11

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

Install

Imports

Quickstart

This quickstart demonstrates how to use `plaster-pastedeploy` to load a WSGI application and server configuration from a `PasteDeploy`-style `.ini` file using the `plaster` API. Importing `plaster_pastedeploy` ensures that `plaster` can correctly parse URIs starting with `config:` that point to `PasteDeploy` configurations. For this example to fully run without errors regarding egg specs, `webtest-app` and `waitress` would need to be installed.

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)

view raw JSON →