Plone内容的别名
项目描述
介绍
此包提供了一个“错误文档”,可用于404响应和一些中间件来触发正确的响应。
如果您在WSGI链中使用repoze.zope2部署Plone网站,则非常有用。当触发错误(例如,404响应)时,您可以转发到Plone中的一个页面,该页面可以显示建议和友好的错误消息。
此外,如果可以在plone.app.redirector的重定向存储中找到别名,将发出自动重定向,将用户带到新页面。
最后,有一个简单的UI用于批量加载重定向。如果您正在从旧网站迁移(可能甚至不是Plone网站),这很有用。以管理员用户身份转到https://127.0.0.1:8080/your-site/@@bulk-load-aliases,并在表单中粘贴旧路径和新路径。
/index.php?pageId=123 => /some-page/some-where
注意:系统会自动将门户网站根路径添加到路径之前。因此,上述在Plone网站'mysite'上运行的示例将导致底层重定向从/mysite/index.php?pageId=123变为/mysite/some-page/some-where。假设您将使用虚拟主机进行部署,使得'mysite'是VHM根,不会作为URL的一部分显示,而是作为重写规则的一部分。
要删除别名,请安装Products.RedirectionTool并使用其用户界面。
安装
collective.fourohfour使用plone.app.registry和z3c.form。
要在自己的构建中使用此产品,您可以在setup.py文件中依赖它,或者在buildout的eggs
列表中添加它,就像正常一样。
在任一情况下,您可能希望使用一组已知的良好软件包来最小化软件包版本冲突的风险。例如
[buildout] ... extends = ... http://good-py.appspot.com/release/plone.autoform/1.0b2 ... [instance] eggs = Plone collective.fourohfour ...
在您的构建中配置后,可以从portal_quickinstaller中正常安装软件包。
提示:您可能还想安装Products.RedirectionTool以获得修改别名的GUI支持。
配置
中间件必须配置为在Paste#httpexceptions之前运行。例如
[filter:errorhandler] use = egg:collective.fourohfour#handler 404 = /@@404-error [filter:errorlog] use = egg:repoze.errorlog#errorlog path = /__error_log__ keep = 50 ignore = paste.httpexceptions:HTTPUnauthorized paste.httpexceptions:HTTPNotFound paste.httpexceptions:HTTPFound [app:zope2] paste.app_factory = repoze.obob.publisher:make_obob repoze.obob.get_root = repoze.zope2.z2bob:get_root repoze.obob.initializer = repoze.zope2.z2bob:initialize repoze.obob.helper_factory = repoze.zope2.z2bob:Zope2ObobHelper zope.conf = /path/to/etc/zope.conf [pipeline:main] pipeline = errorhandler egg:Paste#httpexceptions egg:repoze.retry#retry egg:repoze.tm#tm egg:repoze.vhm#vhm_xheaders errorlog zope2
请注意
* The errorhandler middleware must be configured with a set of response types and the error page to redirect to. To use the "smart" view provided by this package, use /@@404-error. * If you use repoze.vhm for virtual hosting, the view path will be adjusted for the VHM root. Thus, in a typical setup where you virtual- host the Plone site at the root of the domain, a path of /@@404-error will do the right thing. However, if virtual hosting is not enabled, you'll need to adjust the path in the configuration file to include your Plone site, e.g. /my-site/@@404-error * The errorhandler middleware should come just before Paste#httpexceptions
可以使用相同的中间件处理其他类型的响应,例如
[filter:errorhandler] use = egg:collective.fourohfour#handler 404 = /@@404-error 500 = /default_error_message (This middleware is based on Paste#errordocument, but allows more of the original request to be passed through to the error handler, and also allows the error handler to raise 301/302 redirects).
变更日志
1.0a5 - 2011-06-20
更新模板以包含定义,因为Plone 3的全局定义在Plone 4中默认未定义。
1.0a4 - 2010-02-04
由于在repoze.vhm 0.12中已正确处理该问题,因此已恢复到1.0a2路径处理。请勿使用此包的1.0a3版本。[vangheem]
1.0a3 - 2009-12-26
在使用虚拟主机的情况下,存储路径时保留repoze.vhm.virtual_root。这是确保它在Plone的重定向存储中找到唯一方式。[vangheem]
1.0a2 - 2009-08-27
修复缺少middleware.py的损坏发布。
1.0a1 - 2009-08-26
初始发布