[Zope] AccessRule rewriting for queries
Joel Burton
jburton@scw.org
Wed, 14 Mar 2001 21:59:20 -0500 (EST)
Part of my criteria for a site is to eliminate ugly URLs where
possible. So, instead of
http://foo/authors/search?name=plath
I'd like
http://foo/authors/plath
I've handled this (mishandled this?) with a SiteAccess scipt in the
authors folder:
<dtml-comment> Handle author searches like /authors/plath
without ugly URLs like /author/search?name=plath
Look at every request in this folder:
if it's not for an existing file, then mangle
it so that it becomes a request for the detail
page, and set 'author' to the rest of the path
</dtml-comment>
<dtml-let addon="REQUEST.path[-1]">
<dtml-if "addon not in objectIds() and addon[0:6] != 'manage'">
<dtml-call "REQUEST.path.pop()">
<dtml-call "REQUEST.path.append('detail')">
<dtml-call "REQUEST.set('author',addon)">
</dtml-if>
</dtml-let>
(if there is a request for something that isn't actually in this folder,
and isn't a manage request, mungle it)
Two questions:
1) is this terribly evil? is my site going to catch on fire one day
because of this?
2) my breadcrumbs no longer work. I'm using one of the standard breadcrumb
tips that runs off PARENTS, and it only shows 'Home > Authors', not
'Home > Authors > Plath' (which makes sense--Plath isn't on the PARENTS
list.)
However, if I add the requested author name to PARENTS (via append),
everything goes haywire -- I can no longer see the ordinary stuff, like
standard_html_header
I could have a different breadcrumb routine in this folder, but that seems
icky and hard to maintain. I'd rather figure out some way of getting the
regular breadcrumb method to work properly here.
Any ideas?
As always, thanks for any help,
--
Joel Burton <jburton@scw.org>
Director of Information Systems, Support Center of Washington