[Zope] SiteAccess guidelines

Evan Simpson evan@4-am.com
Wed, 12 Jan 2000 16:55:31 -0600


Alexander Limi wrote:

> All folders that do not exist should be redirected to another folder,
> where they might or might not exist.
>
> The way I've tried to implement this is as follows:
>
> All calls to URLs except some selected few (more on this later) are
> redirected to my "artists" folder.
>
> The SiteAccess rewrite rule looks like this:
>
> <dtml-unless "REQUEST.path and REQUEST.path[0][:6]=='manage'">
> <dtml-unless "REQUEST.path and REQUEST.path[0]=='players'">
> <dtml-unless "REQUEST.path and REQUEST.path[0]=='artists'">
>
> Evan, do you hear my call of distress? :)

Surely!  Two notes to start off... first, the request path is a stack, so
'path[0]' is the *final* path element.  You want to test 'path[-1]'.
Second, from my own experience I no longer recommend trying to subtly pick
out management interactions from regular interactions.  Now I just make my
use of the management interface explicit by prefixing everything with 'Z'.
Such a session starts with 'http://mysite.com/Z/manage'.

Now, If you really meant what you said about 'folders that do not exist',
then you might want to try:

<dtml-let path="REQUEST.path">
<dtml-if path>
  <dtml-if expr="path[-1]=='Z'">
    <dtml-call expr="path.pop()">
    <dtml-call expr="REQUEST.setURL(path='Z')">
    <dtml-return expr="'done'">
  </dtml-if>
  <dtml-if expr="path[-1] in objectIds()">
    <dtml-return expr="'done'">
  </dtml-if>
</dtml-if>
  <dtml-call expr="path.append('artists')">
  <dtml-call expr="REQUEST.set('SiteRootPATH', '/')">
</dtml-let>

If, on the other hand, you really do just want to list names to be left
alone, change "path[-1] in objectIds()" to "path[-1] in ['artists',
'players', ...]"

Cheers,

Evan @ 4-am