Install & Compatibility
Where this runs
tested against v3.1.0 · 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
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.106s · 17.9MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.6s · import 0.102s · 18MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
loadapp
✓ from paste.deploy import loadapp
✗ import pastedeploy.loadapp
PasteDeploy's main functions are typically imported directly from the `paste.deploy` namespace, not as submodules of `pastedeploy`.
loadserver
✓ from paste.deploy import loadserver
loadfilter
✓ from paste.deploy import loadfilter
appconfig
✓ from paste.deploy import appconfig
This quickstart demonstrates how to define a WSGI application factory, configure it in an `INI` file, and load it using `paste.deploy.loadapp`. It also shows how to pass `global_conf` values and use `eval()` to pull environment variables into the configuration, which is a common pattern for sensitive values (though with security caveats as noted in warnings). Running this code will create a temporary `config.ini`, load a dummy WSGI app, print its configuration, and then clean up.
import os
import sys
from io import StringIO
from paste.deploy import loadapp
# --- 1. Create a dummy config.ini for demonstration ---
# This config uses 'call:__main__:create_app' to reference an app factory
# defined directly in this script. It also shows `eval` for env vars.
config_content = """
[app:main]
use = call:__main__:create_app
some_setting = hello
another_setting = world
my_env_var = eval(os.environ.get('QUICKSTART_ENV_VAR', 'default_env_val'))
[server:main]
use = egg:waitress#main # Waitress is a common WSGI server
host = 127.0.0.1
port = 8080
"""
with open("config.ini", "w") as f:
f.write(config_content)
# --- 2. Define the WSGI application factory ---
# This factory function will be called by PasteDeploy to create the app.
# It receives `global_conf` and other settings from the INI file.
def create_app(global_conf, some_setting, another_setting, my_env_var):
# Using wsgiref.simple_server.demo_app as a placeholder WSGI app
from wsgiref.simple_server import demo_app
print(f"[create_app] App factory called with global_conf: {global_conf}")
print(f"[create_app] some_setting: {some_setting}")
print(f"[create_app] another_setting: {another_setting}")
print(f"[create_app] my_env_var (from os.environ via eval): {my_env_var}")
return demo_app
# --- 3. Load the application using paste.deploy ---
print("\n--- Attempting to load WSGI application from config.ini ---")
# Set an environment variable for testing `eval` in the config.
os.environ['QUICKSTART_ENV_VAR'] = 'set_from_env_value'
# `global_conf` is passed to the app factory (read-only configuration).
# The '#main' refers to the `[app:main]` section in config.ini.
try:
app = loadapp('config:config.ini#main', global_conf={'process_id': os.getpid(), 'api_key': os.environ.get('PASTEDEPLOY_API_KEY', '')})
print(f"Successfully loaded WSGI application: {app}")
# Verify the loaded app is callable (a basic WSGI check)
assert callable(app)
# A minimal test of the WSGI app (not actually running a server)
response_body = []
def start_response(status, headers):
pass
list(app({'REQUEST_METHOD': 'GET', 'PATH_INFO': '/'}, start_response))
print("WSGI app is callable and passes a basic test.")
finally:
# --- 4. Clean up (important for a self-contained quickstart) ---
os.remove("config.ini")
if 'QUICKSTART_ENV_VAR' in os.environ:
del os.environ['QUICKSTART_ENV_VAR']
print("\n--- Cleanup: Removed config.ini and environment variable ---")
paster --version
Debug
Known issues
gotchaUsing `eval()` directly in PasteDeploy configuration files (`.ini`) can pose a security risk. If an untrusted user can modify the configuration file, they could inject and execute arbitrary Python code.fixAvoid `eval()` for dynamic configuration values if the configuration source is untrusted. Prefer explicit environment variable lookups or secure configuration management systems. If `eval()` is necessary, ensure the configuration file's integrity and source are highly trusted.
affects: All versions
gotchaThe `global_conf` dictionary passed to app factories is typically a shallow copy or reference to the entire configuration. Modifying `global_conf` within an app factory or middleware can lead to unexpected side effects, especially if the same `global_conf` object is reused across multiple components.fixTreat `global_conf` as read-only. If a component needs to store or modify its own state, use `local_conf` or instance attributes. Avoid passing sensitive information directly in `global_conf` from a file; prefer environment variables or secure vault integrations, potentially accessed within the app factory.
affects: All versions
breakingVersions of PasteDeploy prior to 2.0.0 supported Python 2. Versions 2.0.0 and later are Python 3-only. Migrating from older projects will require significant code changes for Python 3 compatibility, beyond just updating PasteDeploy itself.fixUpgrade your entire project to Python 3. Ensure all dependencies are Python 3 compatible. Review `pastedeploy`'s changelog for `2.0.0` and subsequent versions for specific API changes related to Python 3. The `pastedeploy` package itself requires Python 3.7+ as of version 3.x.
affects: < 2.0.0 to >= 2.0.0
gotchaPasteDeploy configuration for application factories can use `egg:package_name#entry_point` or `call:module_name:factory_function`. Developers often confuse these, especially how `egg:` relies on `setuptools` entry points vs. `call:` which requires the module to be importable and the factory function directly discoverable.fixUnderstand the difference: `egg:` is for applications installed as Python packages that register `setuptools` entry points (e.g., `pastedeploy.app_factory` entry points). `call:` is for directly importing a function or callable from a module path. For local development or simple scripts, `call:` is often easier to use directly with a Python file, while `egg:` is common for reusable middleware or frameworks.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pastedeploy'
The 'pastedeploy' library is not installed in the Python environment being used, or the Python environment is not correctly configured to find it.
fixInstall the library using pip: `pip install pastedeploy`.
ImportError: No module named paste.deploy
This error typically occurs in older projects or environments where 'pastedeploy' might be expected under the 'paste' namespace, or 'pastedeploy' itself is missing.
fixEnsure the 'pastedeploy' library is installed and up-to-date: `pip install -U pastedeploy`. If using an older project, verify compatibility or ensure `paste` is also installed if it's a dependency for older configurations.
LookupError: Entry point 'main' not found in egg 'YourProjectName'
PasteDeploy cannot find the specified application factory entry point (e.g., 'main') within your Python package (egg), often due to an incorrect 'entry_points' definition in 'setup.py' or if the package is not properly installed/developed.
fixVerify that your `setup.py` file contains an `entry_points` section with `paste.app_factory` defined correctly, for example: `entry_points={'paste.app_factory': ['main = your_package.module:your_app_factory']}`. Also, ensure your project is installed in the active environment, typically with `pip install -e .` for development mode. ConfigParser.NoSectionError: No section: 'app:main'
The PasteDeploy INI configuration file (e.g., 'development.ini' or 'production.ini') is missing the required '[app:main]' section, or the application is being loaded with a different name than defined in the configuration.
fixEdit your INI configuration file to ensure it includes the expected section, such as `[app:main]` or `[server:main]`, with the correct `use = ...` directive. For example:
```ini
[app:main]
use = egg:YourProject#your_app_factory
[server:main]
use = egg:Paste#http
```
Upgrade
Version history
3.1.0latest on PyPI · released Nov 21, 2023
Audit
Dependencies
No dependency data recorded yet.