0
  C   ˆl–Ðz¾”Šj"Tâ‚À½q¶”Å£�þDAº³�”�ÆèdzW�üÿÂ„Zd?Á_ŠI|¥�+Wé3ž¯ÁÀ ,§    """CherryPy is a pythonic, object-oriented HTTP framework.

CherryPy consists of not one, but four separate API layers.

The APPLICATION LAYER is the simplest. CherryPy applications are written as
a tree of classes and methods, where each branch in the tree corresponds to
a branch in the URL path. Each method is a 'page handler', which receives
GET and POST params as keyword arguments, and returns or yields the (HTML)
body of the response. The special method name 'index' is used for paths
that end in a slash, and the special method name 'default' is used to
handle multiple paths via a single handler. This layer also includes:

 * the 'exposed' attribute (and cherrypy.expose)
 * cherrypy.quickstart()
 * _cp_config attributes
 * cherrypy.tools (including cherrypy.session)
 * cherrypy.url()

The ENVIRONMENT LAYER is used by developers at all levels. It provides
information about the current request and response, plus the application
and server environment, via a (default) set of top-level objects:

 * cherrypy.request
 * cherrypy.response
 * cherrypy.engine
 * cherrypy.server
 * cherrypy.tree
 * cherrypy.config
 * cherrypy.thread_data
 * cherrypy.log
 * cherrypy.HTTPError, NotFound, and HTTPRedirect
 * cherrypy.lib

The EXTENSION LAYER allows advanced users to construct and share their own
plugins. It consists of:

 * Hook API
 * Tool API
 * Toolbox API
 * Dispatch API
 * Config Namespace API

Finally, there is the CORE LAYER, which uses the core API's to construct
the default components which are available at higher layers. You can think
of the default components as the 'reference implementation' for CherryPy.
Megaframeworks (and advanced users) may replace the default components
with customized or extended components. The core API's are:

 * Application API
 * Engine API
 * Request API
 * Server API
 * WSGI API

These API's are described in the `CherryPy specification
<https://github.com/cherrypy/cherrypy/wiki/CherryPySpec>`_.
"""

try:
    import importlib.metadata as importlib_metadata
except ImportError:
    # fall back for python <= 3.7
    # This try/except can be removed with py <= 3.7 support
    import importlib_metadata

from threading import local as _local

from ._cperror import (
    HTTPError, HTTPRedirect, InternalRedirect,
    NotFound, CherryPyException,
)

from . import _cpdispatch as dispatch

from ._cptools import default_toolbox as tools, Tool
from ._helper import expose, popargs, url

from . import _cprequest, _cpserver, _cptree, _cplogging, _cpconfig

import cherrypy.lib.httputil as _httputil

from ._cptree import Application
from . import _cpwsgi as wsgi

from . import process
try:
    from .process import win32
    engine = win32.Win32Bus()
    engine.console_control_handler = win32.ConsoleCtrlHandler(engine)
    del win32
except ImportError:
    engine = process.bus

from . import _cpchecker

__all__ = (
    'HTTPError', 'HTTPRedirect', 'InternalRedirect',
    'NotFound', 'CherryPyException',
    'dispatch', 'tools', 'Tool', 'Application',
    'wsgi', 'process', 'tree', 'engine',
    'quickstart', 'serving', 'request', 'response', 'thread_data',
    'log', 'expose', 'popargs', 'url', 'config',
)


__import__('cherrypy._cptools')
__import__('cherrypy._cprequest')


tree = _cptree.Tree()


try:
    __version__ = importlib_metadata.version('cherrypy')
except Exception:
    __version__ = 'unknown'


engine.listeners['before_request'] = set()
engine.listeners['after_request'] = set()


engine.autoreload = process.plugins.Autoreloader(engine)
engine.autoreload.subscribe()

engine.thread_manager = process.plugins.ThreadManager(engine)
engine.thread_manager.subscribe()

engine.signal_handler = process.plugins.SignalHandler(engine)


class _HandleSignalsPlugin(object):
    """Handle signals from other processes.

    Based on the configured platform handlers above.
    """

    def __init__(self, bus):
        self.bus = bus

    def subscribe(self):
        """Add the handlers based on the platform."""
        if hasatt