Skip to content

Commit

Permalink
Application-as-extension.
Browse files Browse the repository at this point in the history
  • Loading branch information
amcgregor committed Oct 1, 2017
1 parent cf856b6 commit d0e5423
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions web/core/application.py
Expand Up @@ -42,6 +42,9 @@ class Application(object):
* Collection and execution of `web.extension` callbacks.
* WSGI middleware wrapping.
* The final WSGI application handling requests.
The application object is treated as an extension allowing per-application customization utilizing extension
callbacks (such as rendering custom views on startup) through subclassing.
"""

__slots__ = (
Expand All @@ -53,6 +56,8 @@ class Application(object):
'__call__', # WSGI request handler. Dynamically assigned.
)

last = True

def __init__(self, root, **config):
"""Construct the initial ApplicationContext, populate, and prepare the WSGI stack.
Expand Down Expand Up @@ -124,6 +129,8 @@ def _configure(self, config):
arguments.JSONKwargsExtension(),
])

config['extensions'].append(self) # Allow the application object itself to register callbacks.

# Tests are skipped on these as we have no particular need to test Python's own logging mechanism.
level = config.get('logging', {}).get('level', None)
if level: # pragma: no cover
Expand Down

0 comments on commit d0e5423

Please sign in to comment.