File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/cherrypy/__pycache__/_cpmodpy.cpython-310.pyc
Back
o ;jY+ � @ s� d Z ddlZddlZddlZddlZddlZddlmZ ddlZddl m Z mZ ddlm Z dd� ZG dd � d �Zd Zd add� Zdd d�Zz ddlZdd� ZW n ey] dd� ZY nw ddd�ZG dd� de�ZdS )aW Native adapter for serving CherryPy via mod_python. Basic usage: ########################################## # Application in a module called myapp.py ########################################## import cherrypy class Root: @cherrypy.expose def index(self): return 'Hi there, Ho there, Hey there' # We will use this method from the mod_python configuration # as the entry point to our application def setup_server(): cherrypy.tree.mount(Root()) cherrypy.config.update({'environment': 'production', 'log.screen': False, 'show_tracebacks': False}) ########################################## # mod_python settings for apache2 # This should reside in your httpd.conf # or a file that will be loaded at # apache startup ########################################## # Start DocumentRoot "/" Listen 8080 LoadModule python_module /usr/lib/apache2/modules/mod_python.so <Location "/"> PythonPath "sys.path+['/path/to/my/application']" SetHandler python-program PythonHandler cherrypy._cpmodpy::handler PythonOption cherrypy.setup myapp::setup_server PythonDebug On </Location> # End The actual path to your mod_python.so is dependent on your environment. In this case we suppose a global mod_python installation on a Linux distribution such as Ubuntu. We do set the PythonPath configuration setting so that your application can be found by from the user running the apache2 instance. Of course if your application resides in the global site-package this won't be needed. Then restart apache2 and access http://127.0.0.1:8080 � N)�always_iterable)� format_exc� bare_error)�httputilc s@ ddl m� ��� }d|v rD|d �� D ]/}|�dd�}t|�dkr-t|d t� t� �}q|\}}t|t� t� |g�}t||�}|� qt j �dddgd �� t j�t �d �r\�j�� t �d�rf�j�� �j�� t j�� ��d�� �fd d��}��� �fdd�} z� �| � W d S ty� �j��| � Y d S w )Nr ��apachezcherrypy.setupz::� FTZRange)z log.screenztools.ignore_headers.onztools.ignore_headers.headers�signal_handler�console_control_handler�logc sN � j }tj|kr� j}ntj|kr� j}ntj|kr� j}� �| |�j � d S �N) Z APLOG_ERR�logging�DEBUGZAPLOG_DEBUG�INFOZ APLOG_INFO�WARNINGZ APLOG_WARNINGZ log_error�server)�msg�level�newlevel)r �req� �E/opt/saltstack/salt/lib/python3.10/site-packages/cherrypy/_cpmodpy.py�_logh s zsetup.<locals>._logc s � � � d S r )�exit)�data)�enginer r �cherrypy_cleanupx s zsetup.<locals>.cherrypy_cleanup)� mod_pythonr �get_options�split�len� __import__�globals�locals�getattr�cherrypyZconfig�updater �hasattrr Zunsubscriber Z autoreloadr Z subscribe�startZregister_cleanup�AttributeError) r �options�functionZatoms�mod�modname�fname�funcr r r )r r r r �setupJ s>