移动设备检测库与wsgi中间件
mobi.devices的Python项目详细描述
请参阅http://mobi.infrae.com/上的文档。
mobi.devices是一组检测移动用户代理的工具。它使用 以及来自 这是MIT mobile project。
它提供了wsgi中间件,可以用有关 执行请求的设备。
为了获得最佳性能,请安装pytc。这不是包装要求 因为它不是在所有平台上都可用。
粘贴示例配置:
[app:yourapp] # This part describes your application # use = ... [filter:mobidevicedetection] # The entry point to use the classifier use = egg:mobi.devices#classifier # cache the classification on a client side cookie (default: true) cookie_cache = true # Configure caching (see beaker documentation) cache.type = ext:memcached cache.url = 127.0.0.1:11211 cache.lock_dir = /tmp/mobicache # Data directory *required*. make sure directory is writable # by the user that run the webserver var = /var/mobi/db # Path to wurfl file. by default it uses the one shipped with # this package. however you should use the latest one. wurfl_file = /var/mobi/wurfl.xml.gz [filter:mobirouter] use = egg:mobi.devices#router # Redirect mobile devices that connect to infrae.com hostname # to m.infrae.com infrae.com = http://m.infrae.com/ [pipeline:main] # This part configures the actual WSGI stack pipeline = mobidevicedetection mobirouter yourapp [server:main] # This is the configuration for the paster web server. # It must have the same name as the pipeline. use = egg:Paste#http host = 0.0.0.0 port = 8080 threadpool_workers = 7
如果您使用的是带有修改路径和 如果希望路由器在原始路径上路由,请添加 在任何重写规则之前遵循规则
RewriteRule ^(.*)$ - [E=ORIGINAL_PATH:$1] RequestHeader set X_ORIGINAL_PATH %{ORIGINAL_PATH}e
变更日志
移动设备1.2(2011-04-14)
- 添加更多配置选项(bruno binet)
移动设备1.1(2010-12-20)
- 添加原始路径http头处理程序以使路由器使用重写规则。
- 添加简单的路由器中间件。
移动设备1.0.1(2010-09-14)
- 修复wurfl文件配置处理
- 修复丢失的导入
移动设备1.0(2010-09-13)
- 为wurfl添加新引擎
移动设备1.0b1(2010-07-14)
- 第一个版本,请参阅README.txt