### Application Section Example (Custom App) Source: https://github.com/pylons/pastedeploy/blob/main/docs/index.md Defines an application that is loaded from an egg, passing specific configuration parameters. ```ini [app:blogapp] use = egg:BlogApp database = sqlite:/home/me/blog.db ``` -------------------------------- ### Python Setup for Eggs Source: https://github.com/pylons/pastedeploy/blob/main/docs/index.md Modifies a standard distutils setup.py to use setuptools for creating Python Eggs. ```python from setuptools import setup ``` -------------------------------- ### Install Paste Deploy from development source Source: https://github.com/pylons/pastedeploy/blob/main/docs/index.md Install Paste Deploy directly from its development source repository. This is useful for tracking the latest changes or contributing to the project. ```bash git clone https://github.com/Pylons/pastedeploy cd pastedeploy pip install -e . ``` -------------------------------- ### Application Section Example (Static Files) Source: https://github.com/pylons/pastedeploy/blob/main/docs/index.md Defines a simple application for serving static files, specifying the document root using variable substitution. ```ini [app:home] use = egg:Paste#static document_root = %(here)s/htdocs ``` -------------------------------- ### Install Paste Deploy using pip Source: https://github.com/pylons/pastedeploy/blob/main/docs/index.md Install Paste Deploy using pip. This command installs the latest stable version of the package. ```bash pip install PasteDeploy ``` -------------------------------- ### Example Paste Deploy Configuration File Source: https://github.com/pylons/pastedeploy/blob/main/docs/index.md A typical configuration file demonstrating how to mount multiple applications using composite sections and defining individual application and filter-app sections. ```ini [composite:main] use = egg:Paste#urlmap / = home /blog = blog /wiki = wiki /cms = config:cms.ini [app:home] use = egg:Paste#static document_root = %(here)s/htdocs [filter-app:blog] use = egg:Authentication#auth next = blogapp roles = admin htpasswd = /home/me/users.htpasswd [app:blogapp] use = egg:BlogApp database = sqlite:/home/me/blog.db [app:wiki] use = call:mywiki.main:application database = sqlite:/home/me/wiki.db ``` -------------------------------- ### Server Factory Example Source: https://github.com/pylons/pastedeploy/blob/main/docs/index.md This factory creates a WSGI server. It takes host and port configuration and returns a callable that serves a given WSGI application indefinitely. ```python def server_factory(global_conf, host, port): port = int(port) def serve(app): s = Server(app, host=host, port=port) s.serve_forever() return serve ``` -------------------------------- ### Pipeline Configuration Example Source: https://github.com/pylons/pastedeploy/blob/main/docs/index.md Defines a pipeline application with multiple filters and a final application. Filters are applied in reverse order of definition. ```ini [pipeline:main] pipeline = filter1 egg:FilterEgg#filter2 filter3 app [filter:filter1] # ... ``` -------------------------------- ### Pipeline Composite Factory Example Source: https://github.com/pylons/pastedeploy/blob/main/docs/index.md An example of a composite factory that constructs a WSGI pipeline from a list of filters and an application, using a loader object. ```python def pipeline_factory(loader, global_config, pipeline): # space-separated list of filter and app names: pipeline = pipeline.split() filters = [loader.get_filter(n) for n in pipeline[:-1]] app = loader.get_app(pipeline[-1]) filters.reverse() # apply in reverse order! for filter in filters: app = filter(app) return app ``` -------------------------------- ### Install PasteDeploy development version Source: https://github.com/pylons/pastedeploy/blob/main/docs/index.md Install the development version of PasteDeploy using pip. This command allows you to install directly from a Git repository or a specific development branch. ```bash pip install PasteDeploy==dev ``` -------------------------------- ### Filter-App Section Example Source: https://github.com/pylons/pastedeploy/blob/main/docs/index.md Shows a filter-app section that applies a filter (e.g., authentication) to a subsequent application. ```ini [filter-app:blog] use = egg:Authentication#auth next = blogapp roles = admin htpasswd = /home/me/users.htpasswd ``` -------------------------------- ### Application Section Example (Direct Call) Source: https://github.com/pylons/pastedeploy/blob/main/docs/index.md Defines an application by directly referencing a variable within a Python module, useful for applications not packaged as eggs. ```ini [app:wiki] use = call:mywiki.main:application database = sqlite:/home/me/wiki.db ``` -------------------------------- ### INI Configuration File Format Example Source: https://github.com/pylons/pastedeploy/blob/main/docs/index.md Illustrates the basic INI format used for PasteDeploy configuration files, including sections, key-value pairs, and multi-line values. ```ini [section_name] key = value another key = a long value that extends over multiple lines ``` -------------------------------- ### Composite Section Example Source: https://github.com/pylons/pastedeploy/blob/main/docs/index.md Illustrates a composite section used for dispatching requests to other applications based on path prefixes. ```ini [composite:main] use = egg:Paste#urlmap / = home /blog = blog /cms = config:cms.ini ``` -------------------------------- ### Install PasteScript using pip Source: https://github.com/pylons/pastedeploy/blob/main/docs/index.md Install the complementary PasteScript package using pip. PasteScript is often used in conjunction with Paste Deploy for managing applications. ```bash pip install PasteScript ``` -------------------------------- ### Build Documentation Source: https://github.com/pylons/pastedeploy/blob/main/contributing.md Build the project's documentation using tox. ```bash $ tox -e docs ``` -------------------------------- ### Configuration with Keyword Arguments in PasteDeploy Source: https://github.com/pylons/pastedeploy/blob/main/docs/index.md Shows how to pass configuration settings as keyword arguments to an application factory by adding extra keys to the application's section. ```ini [app:blog] use = egg:MyBlog database = mysql://localhost/blogdb blogname = This Is My Blog! ``` -------------------------------- ### Global Configuration and Local Overrides in PasteDeploy Source: https://github.com/pylons/pastedeploy/blob/main/docs/index.md Demonstrates how to define global configuration in the [DEFAULT] section and override specific global settings locally using the 'set' prefix. ```ini [DEFAULT] admin_email = webmaster@example.com [app:main] use = ... set admin_email = bob@example.com ``` -------------------------------- ### Loading WSGI Application with paste.deploy.loadapp Source: https://github.com/pylons/pastedeploy/blob/main/docs/index.md Demonstrates the primary method for loading a WSGI application using a configuration URI with the `paste.deploy.loadapp` function. ```python from paste.deploy import loadapp wsgi_app = loadapp('config:/path/to/config.ini') ``` -------------------------------- ### Defining Application Factory in PasteDeploy Source: https://github.com/pylons/pastedeploy/blob/main/docs/index.md Demonstrates how to define an application in PasteDeploy by directly pointing to a Python application factory using a specific protocol. ```ini [app:myapp] paste.app_factory = myapp.modulename:app_factory ``` -------------------------------- ### Composite Application with URL Mapping in PasteDeploy Source: https://github.com/pylons/pastedeploy/blob/main/docs/index.md Shows how to define a composite application that maps different URL paths to different applications, such as a URL mapper. ```ini [composite:main] use = egg:Paste#urlmap / = mainapp /files = staticapp [app:mainapp] use = egg:MyApp [app:staticapp] use = egg:Paste#static document_root = /path/to/docroot ``` -------------------------------- ### Applying Filters with 'filter-with' in PasteDeploy Source: https://github.com/pylons/pastedeploy/blob/main/docs/index.md Demonstrates how to apply a filter to an application using the 'filter-with' setting in the application's section, referencing a filter defined elsewhere. ```ini [app:main] use = egg:MyEgg filter-with = printdebug [filter:printdebug] use = egg:Paste#printdebug ``` -------------------------------- ### Defining Egg Entry Points Source: https://github.com/pylons/pastedeploy/blob/main/docs/index.md Configures entry points for PasteDeploy applications within a Python Egg's setup.py. Specifies application factories for 'paste.app_factory'. ```python setup( name='MyApp', # ... entry_points={ 'paste.app_factory': [ 'main=myapp.mymodule:app_factory', 'ob2=myapp.mymodule:ob_factory'], }, ) ``` -------------------------------- ### Referencing Other Applications in PasteDeploy Source: https://github.com/pylons/pastedeploy/blob/main/docs/index.md Shows how to define an application in PasteDeploy by referencing another configuration file, an egg, a callable, or another section. ```ini [app:myapp] use = config:another_config_file.ini#app_name ``` ```ini [app:myotherapp] use = egg:MyApp ``` ```ini [app:mythirdapp] use = call:my.project:myapplication ``` ```ini [app:mylastapp] use = myotherapp ``` -------------------------------- ### Run Tests for Python 3.7 Source: https://github.com/pylons/pastedeploy/blob/main/contributing.md Execute the test suite specifically for Python 3.7 using tox. ```bash $ tox -e py37 ``` -------------------------------- ### Overriding Configuration in PasteDeploy Source: https://github.com/pylons/pastedeploy/blob/main/docs/index.md Illustrates how to override settings from a base application in another section by referencing the base application and providing new values. ```ini [app:otherblog] use = blog blogname = The other face of my blog ``` -------------------------------- ### Paste.app_factory Signature Source: https://github.com/pylons/pastedeploy/blob/main/docs/index.md Defines the signature for a paste.app_factory callable, which accepts global configuration and local configuration arguments, returning a WSGI application. ```python def app_factory(global_config, **local_conf): return wsgi_app ``` -------------------------------- ### Composite Application Configuration Source: https://github.com/pylons/pastedeploy/blob/main/docs/index.md Configures a composite application using a custom pipeline factory. Specifies the pipeline components including filters and the main application. ```ini [composite:main] use = pipeline = egg:Paste#printdebug session myapp [filter:session] use = egg:Paste#session store = memory [app:myapp] use = egg:MyApp ``` -------------------------------- ### PasteDeploy Configuration for Chained Filters Source: https://github.com/pylons/pastedeploy/blob/main/docs/index.md This INI configuration demonstrates how to chain filters in PasteDeploy, where one filter (`app_filter`) uses another application (`next_app`) as its backend. ```ini [app-filter:app_name] use = egg:... next = next_app [app:next_app] # ... ``` -------------------------------- ### Variable Setting in PasteDeploy Source: https://github.com/pylons/pastedeploy/blob/main/docs/news.md Allows importing global variables into the local scope for use within PasteDeploy configurations. ```ini get local_var = global_var_name ``` -------------------------------- ### Paste.composite_factory Signature Source: https://github.com/pylons/pastedeploy/blob/main/docs/index.md Defines the signature for a paste.composite_factory callable, which receives a loader object, global configuration, and local configuration. ```python def composite_factory(loader, global_config, **local_conf): return wsgi_app ``` -------------------------------- ### Authentication Filter Factory Source: https://github.com/pylons/pastedeploy/blob/main/docs/index.md Use this factory to create a WSGI filter that performs basic authentication based on the REMOTE_USER environment variable. It requires a space-separated string of allowed usernames. ```python def auth_filter_factory(global_conf, req_usernames): # space-separated list of usernames: req_usernames = req_usernames.split() def filter(app): return AuthFilter(app, req_usernames) return filter class AuthFilter(object): def __init__(self, app, req_usernames): self.app = app self.req_usernames = req_usernames def __call__(self, environ, start_response): if environ.get('REMOTE_USER') in self.req_usernames: return self.app(environ, start_response) start_response( '403 Forbidden', [('Content-type', 'text/html')]) return ['You are forbidden to view this resource'] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.