cherrypy._cpmodpy模块

用于通过mod_python提供CherryPy的本机适配器

基本用法:

#myapp.py模块中的应用程序

导入cherrypy

类根:

@cherrypy.expose def index(Self):

返回‘Hi There,Ho There,嘿There’

#我们将使用mod_python配置中的此方法#作为应用程序def setup_server()的入口点:

cherrypy.tree.mount(Root())cherrypy.config.update({‘Environment’:‘Production’,

‘log.screen’:false,‘show_traceback’:false})

#或将在#Apache启动时加载的文件#

#Start DocumentRoot“/”监听8080 LoadModule python_module/usr/lib/apache2/module/mod_python.so

<位置“/”>

PythonPath“sys.path+ ['/path/to/my/application'] “SetHandler python-program PythonHandler cherrypy._cpmodpy::Handler PythonOption cherrypy.setup myapp::setup_server PythonDebug on

</location>#end

mod_python.so的实际路径取决于您的环境。在本例中,我们假设在Linux发行版(如Ubuntu)上安装全局mod_python。

我们确实设置了PythonPath配置设置,以便可以通过运行apache2实例的用户找到您的应用程序。当然,如果您的应用程序驻留在全局站点包中,则不需要这样做。

然后重新启动apache2并访问http://127.0.0.1:8080

class cherrypy._cpmodpy.ModPythonServer(loc='/', port=80, opts=None, apache_path='apache', handler='cherrypy._cpmodpy::handler')[源代码]

基类:object

start()[源代码]
stop()[源代码]
template = '\n# Apache2 server configuration file for running CherryPy with mod_python.\n\nDocumentRoot "/"\nListen %(port)s\nLoadModule python_module modules/mod_python.so\n\n<Location %(loc)s>\n    SetHandler python-program\n    PythonHandler %(handler)s\n    PythonDebug On\n%(opts)s\n</Location>\n'
class cherrypy._cpmodpy._ReadOnlyRequest(req)[源代码]

基类:object

expose = ('read', 'readline', 'readlines')
cherrypy._cpmodpy.handler(req)[源代码]
cherrypy._cpmodpy.popen(fullcmd)[源代码]
cherrypy._cpmodpy.read_process(cmd, args='')[源代码]
cherrypy._cpmodpy.send_response(req, status, headers, body, stream=False)[源代码]
cherrypy._cpmodpy.setup(req)[源代码]