[Framework-Team] PLIP125 (link integrity) part II - redirect-on-move ready for merge
Martin Aspeli
optilude at gmx.net
Sun Dec 24 00:25:03 UTC 2006
Hi guys,
I've spent the past two days piecing together RedirectionTool and Whit's
topp.rose product into something that meets the second half of PLIP125.
The first half is what Andreas is working on - warning when you're about
to delete things that will break links. The second half is about
offering automatic redirects or, if not possible, useful guesses instead
of a dumb 404 page when an object has been moved or renamed.
I found it easier to start from scratch and borrow code, logic and ideas
from the two products (RedirectionTool and topp.rose) than to try and
merge the two since the former has a slightly different use case (it's
about explicit redirects created manually) and the latter wasn't in a
finished state and anyway needed updating for Zope 2.10.
For the record, I love this functionality :)
I'd like to merge this now, unless people have objections. There's no
bundle, but the code is here:
http://dev.plone.org/plone/browser/plone.app.redirector/trunk
http://dev.plone.org/plone/browser/CMFPlone/branches/plip125-redirector
The CMFPlone branch does the following:
- poke plone.app.redirector in configure.zcml
- register the IRedirectionStorage local utility in componentregistry.xml
- a migration for the above (tested)
- make the default_error_message.pt use @@plone_redirector_view to
perform a redirect or offer suggestions
- a couple of fixes for the new icon stuff that were surfacing in my
testing (too lazy to do it on trunk, since I expect we'll merge this
anyway - if not for some reason, I'll move to trunk)
plone.app.redirector does the following:
- A local utility, IRedirectionStorage, can keep track of old-path to
new-path mappings. It's smart enough to deal with circular references
(ignored), and transitive aliases (a -> b; b -> c becomes a -> c),
multiple object moves, etc.
- Event handlers for IObjectMovedEvent (object is renamed or moved to
a different folder, so make an alias from old path to new path) and
IObjectRemovedEvent (object deleted so remove any references to it)
- A view, @@plone_redirector_view, can perform a redirect or search
for sensible objects based on the URL in question. (note, this should be
VHM safe because it uses REQUEST.physicalPathToURL() and
physicalPathFromURL()).
- Good test coverage :-)
Note that unlike topp.rose, I didn't (yet) opt to go for something very
automatic, such as a new traverser that traversed to aliases when
necessary or a view on the NotFound exception ala LinkIntegrity, because
it felt a bit dangerous and intrusive. Using default_error_message.pt is
probably a bit slower (it has to render the page, then perform a
redirect, rather than let a custom traverser do it), so we could move to
a traverser (but it may conflict with more specific traversers from
other components, for example) or a view on the NotFound exception is
need be - I'd just rather start off simple.
Also, unlike RedirectionTool, there is no form for making your own
redirects (mainly because there's no good selection widget for me to
use). This would work just fine (add things to the IRedirectionStorage
utility), but since we have automatic redirects for anything moved or
renamed, I think it's much less useful... in any case, it can be added
later.
I'd like to merge before trunk moves too far away from my branch. :)
Martin
More information about the Framework-Team
mailing list