哦,左中。
oops_wsgi的Python项目详细描述
Copyright (c) 2011, Canonical Ltd
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, version 3 only.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. GNU Lesser General Public License version 3 (see the file LICENSE).
oops_wsgi包在wsgi web服务器和 oops错误报告系统(http://pypi.python.org/pypi/oops)。
依赖关系
- python 2.6+或3.3+
- 哎呀(http://pypi.python.org/pypi/oops)
测试依赖项
用法
oops_wsgi提供了与oops.config的集成,允许在 要集中收集的web应用程序,带有回溯和其他诊断 信息。
通常,类似于这样:
设置您的配置:
>>> from oops import Config >>> config = Config()
请注意,您可能需要至少一个发布者,或者您的报告将 被丢弃。
将特定于wsgi的钩子添加到配置:
>>> oops_wsgi.install_hooks(config)
这是一个方便的功能-欢迎您挑选 或者从oops-wsgi.hooks中筛选所需的钩子。
正常创建您的wsgi应用程序,然后包装它:
>>> app = oops_wsgi.make_app(app, config)
如果通过这个中间件出现异常,将记录oops。如果 请求的主体尚未启动,则显示一个自定义页 显示oops id,异常被吞入。表明 像套接字上的文件结尾这样的正常情况不会触发oopse。如果 oops被过滤,或者没有配置发布服务器,那么异常将 向上推进-oops中间件在这些方面不能做任何有用的事情 案例。(例如,如果在oops之上有一个自定义的404中间件 wsgi堆栈中的中间件,并过滤404异常,使它们不会创建 报告,然后如果oops中间件除了提出 异常,您的自定义404中间件无法工作。
如果主体已经启动,则无法将oops id与 客户端和异常将支持wsgi应用程序堆栈。
如果您提供一个接受(environ, 并返回要发送到客户端的HTML。
>>> def myerror_html(environ, report): ... return '<html><body><h1>OOPS! %s</h1></body></html>' % report['id'] >>> app = oops_wsgi.make_app(app, config, error_render=myerror_html)
或者,您可以提供要与报表一起格式化的字符串模板。
>>> json_template='{"oopsid" : "%(id)s"}' >>> app = oops_wsgi.make_app(app, config, error_template=json_template)
有关更多信息,请参阅pydoc oops_wsgi。
安装
在具有所有可用依赖项的环境中运行setup.py,或者 将工作目录添加到pythonpath。
开发
上游开发发生在https://launchpad.net/python-oops-wsgi。 如果依赖项不是 立即可用,您可以使用./bootstrap.py创建bin/buildout,然后 bin/py以获得具有可用依赖项的python解释器。
要使用您选择的运行程序运行测试,测试套件是 oops_wsgi.tests.test_套件。
例如:
$ bin/py -m testtools.run oops_wsgi.tests.test_suite
如果您有testrepository,您可以使用它运行测试:
$ testr run