Skip to main content

克隆内容的别名

项目描述

介绍

这个包提供了一个“错误文档”,可以用于 404 响应和一些中间件来触发正确的响应。

如果您使用 repoze.zope2 在 WSGI 链中部署 Plone 站点,这很有用。当错误(例如触发 404 响应)时,您可以转发到 Plone 中的页面,该页面可以显示建议和友好的错误消息。

此外,如果可以在 plone.app.redirector 的重定向存储中找到别名,则会发出自动重定向,将用户带到新页面。

最后,还有一个用于批量加载重定向的基本 UI。如果您从旧站点(甚至可能不是 Plone 站点)迁移,这很有用。以 Manager 用户身份访问 http://localhost: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 并使用其 UI。

安装

collective.fourohfour 使用 plone.app.registry 和 z3c.form。

要在您自己的构建中使用该产品,要么在 setup.py 文件中依赖它,要么像往常一样将其添加到构建的鸡蛋列表中。

在任何一种情况下,您都可能希望使用一组已知良好的软件包来最大程度地降低软件包版本冲突的风险。例如:

[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

  • 恢复到 1.0a2 路径处理,因为 1.0a3 中修复的问题现在在 repoze.vhm 0.12 中得到正确处理。不要使用这个包的 1.0a3 版本。[万海姆]

1.0a3 - 2009-12-26

  • 如果使用虚拟主机,则存储保留 repoze.vhm.virtual_root 的路径。这是确保它在 Plone 的重定向存储中找到命中的唯一方法。[万海姆]

1.0a2 - 2009-08-27

  • 修复缺少 middleware.py 的损坏版本

1.0a1 - 2009-08-26

  • 初始发行

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

collective.fourohfour-1.0a5.tar.gz (20.3 kB 查看哈希

已上传 source