每一个wsgi应用程序都更适合使用raptor。

raptorizemw的Python项目详细描述


https://github.com/ralphbean/raptorizemw/raw/master/raptorizemw/resources/raptor.png

安装

您可以使用pip自行安装:

$ pip install raptorizemw

或者您可以将raptorizemw添加到 setup.py项目的文件。

金字塔中的用法

编辑myapp/__init__.py并替换return config.make_wsgi_app() 行如下:

import raptorizemw
app = config.make_wsgi_app()
app = raptorizemw.make_middleware(app)
return app

重新启动你的应用程序,但小心猛禽!

在烧瓶中使用

编辑yourapp.py并用以下内容替换app.run()行:

import raptorizemw
app.wsgi_app = raptorizemw.make_middleware(app.wsgi_app)
app.run()

僵尸!

在涡轮齿轮2中的使用

只需编辑myapp/config/middleware.py并将以下内容添加到 make_app(...)

# Wrap your base TurboGears 2 application with custom middleware here
import raptorizemw
app = raptorizemw.make_middleware(app)

在PasteDeploy管道中使用

您还可以将猛禽加入到PasteDeploy管道中,如下所示:

[pipeline:main]
pipeline =
    raptorize
    my-app

[filter:raptorize]
use = egg:raptorizemw
enterOn = konami-code
delayTime = 3000
random_chance = 0.25
only_on_april_1st = True

[app:myapp]
...

实际上,您可以在 WSGI管道,并根据Configuration相应地配置选项 下面一节。

配置

make_middleware(...)RaptorizeMiddleware.__init__(...)都接受 许多配置关键字:

  • ^{tt12}$ can be one of two actions: ‘timer’ or ‘konami-code’. If ‘timer’ is specified, then the raptor is shown on page load. If ‘konami-code’, then the raptor is shown if the page-viewing user enters the sacred sequence. Default is ‘timer’.
  • ^{tt13}$ must be an ^{tt14}$ and is the number of milliseconds until the raptor is shown. Default is 2000.
  • ^{tt15}$ must be a float between 0.0 and 1.0 representing a ‘percent chance’ to load the raptor. A value of 1.0 means the raptor will be injected every time; a value of 0.0 means it will never be injected; a value of 0.5 will result in a 50% chance of raptors. Default is 1.0.
  • ^{tt16}$ should be a ^{tt17}$ value that will restrict raptors only to April Fool’s day. The configuration will coerce Boolean-like strings (such as ^{tt18}$, ^{tt19}$, ^{tt20}$, ^{tt21}$, ^{tt22}$ and ^{tt23}$) into a suitable format if provided in this manner (such as through a text-based pipeline configuration). Default is ^{tt24}$.

例如:

app = raptorizemw.make_middleware(
    app,
    enterOn='konami-code',
    delayTime=500,
    random_chance=0.5,
    only_on_april_1st=True
)

将导致50%的网页加载猛禽在愚人节仅。这些 只有当用户同时输入konami代码时,才会显示raptors,并且 很快,只过了半秒钟。

学分

这个raptorize jquery插件的wsgi分类是编写的 通过Ralph Bean。真正的功劳归于 祖伯,他写了original jquery plugin

获取源

代码和bug跟踪器位于http://github.com/ralphbean/raptorizemw。 请用叉子叉好

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何从旧的ArrayList<ArrayList<Integer>>创建新的ArrayList而不更改旧的?   java JBoss 7 |从随机线程写入jndi   java如何在数据库中有空值的JPA实体中迭代联接列   java Android应用程序在setContentView上崩溃   java如何在表单中预先填充文本字段,其中包含数据库中的信息。jsp?   来自R.raw的java Android文件阅读器。文件   如何将多个WAR(或Java Web应用程序,特别是使用Spring MVC)嵌入到一个承载另一个WAR的网页中?   java动态更新Jlist   gwt分页大结果集Java的最佳方式是什么   JavaCDI:为什么我的瞬态字段被序列化?   使用JAXB更新java XML模板文件   java getGraphics()返回空值   扩展javax的java类。ws。rs.core。无法将应用程序强制转换为Servlet   java方法可能无法在异常时关闭流   公共类的表达式的java非法开始   java年轻一代GC在EXT根扫描上花费了太多时间   使用CXF和具有未发布元数据的WSDL的java