Skip to main content

Aliasing of Plone content

Project description

Introduction

This package provides an “error document” that can be used for 404 responses and some middleware to trigger the correct responses.

It is useful if you are deploying a Plone site in a WSGI chain using repoze.zope2. When an error (e.g. a 404 response is triggered) you can forward to a page in Plone, which can display suggestions and a friendly error message.

Furthermore, if an alias can be found in the redirection storage from plone.app.redirector, an automatic redirect will be issued, taking the user to the new page.

Finally, there is a rudimentary UI to bulk load redirects. This is useful if you are migrating from an old site (perhaps not even a Plone site). Go to http://localhost:8080/your-site/@@bulk-load-aliases as a Manager user, and paste in the old and new paths in the form:

/index.php?pageId=123  =>  /some-page/some-where

Note: The portal root path will be automatically prefixed to the paths. Thus, the example above run on the Plone site ‘mysite’ would result in an underlying redirect of /mysite/index.php?pageId=123 to /mysite/some-page/some-where. The assumption is that you’ll deploy with virtual hosting so that the ‘mysite’ is the VHM root and not shown as part of the URL, but part of rewrite rules.

To remove aliases, install Products.RedirectionTool and use its UI.

Installation

collective.fourohfour uses plone.app.registry and z3c.form.

To use the product in your own build, either depend on it in a setup.py file, or add it to your buildout’s eggs listing as normal.

In either case, you probably want to use a Known Good Set of packages to minimise the risk of package version conflicts. For example:

[buildout]
...
extends =
    ...
    http://good-py.appspot.com/release/plone.autoform/1.0b2

...

[instance]
eggs =
    Plone
    collective.fourohfour
    ...

Once configured in your build, install the package from portal_quickinstaller as normal.

Hint: You may also want to install Products.RedirectionTool to get some GUI support for modifying aliases.

Configuration

The middleware must be configured to be run before Paste#httpexceptions. For example:

[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

Please note:

* 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

It is possible to handle other types of responses with the same middleware, e.g.:

    [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).

Changelog

1.0a5 - 2011-06-20

  • Updated template to include defines as Plone 3 global defines are undefined by default in Plone 4.

1.0a4 - 2010-02-04

  • revert to 1.0a2 path handling since the issue fixed in 1.0a3 is now correctly handled in repoze.vhm 0.12. Do not use the 1.0a3 version of this package. [vangheem]

1.0a3 - 2009-12-26

  • Store paths preserving the repoze.vhm.virtual_root if using virtual hosting. This is the only way to ensure it finds hits in redirection storage for Plone. [vangheem]

1.0a2 - 2009-08-27

  • Fix broken release lacking middleware.py

1.0a1 - 2009-08-26

  • Initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

collective.fourohfour-1.0a5.tar.gz (20.3 kB view details)

Uploaded Source

File details

Details for the file collective.fourohfour-1.0a5.tar.gz.

File metadata

File hashes

Hashes for collective.fourohfour-1.0a5.tar.gz
Algorithm Hash digest
SHA256 e70c07a2e0d20188a955e3967894fd9db3491b40489ba7ea2b1b4008750ee480
MD5 138b83fcfca9269ed0af924dd64fb30e
BLAKE2b-256 85ff5961e9567d4b6798d2bf0fa7f51eae973c9deeaa801a8e3f020579955cc4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page