[Zope-dev] Site Access Rewrite Rule documentation?

Evan Simpson evan@4-am.com
Sat, 3 Mar 2001 23:22:31 -0600


From: "R. David Murray " <bitz@bitdance.com>
> So, clearly I don't have a clue what stack is supposed to contain or
> what changing it does.  Can anyone point me to docs or give me some
> help?  You can also tell me, "that's stupid, just solve your problem
> this way"...

You've got it almost right, you just have to know that it's called a stack
because it's used that way by the publishing machinery.  This means that the
names on the stack are always in *reverse* order of how they appear in a
URL; "stack[-1]" is the next name to be traversed, not "stack[0]".

As you inferred, changing the stack will change the publishing path, and
your code, suitably adjusted, should do what you wanted.  Something like
this (in "/", not "/Books"):

stack = context.REQUEST['TraversalRequestNameStack']
if len(stack) >=2 and stack[-1] == 'Books' and stack[-2][:6] != 'manage':
    stack[-1:] = ['marketItems', 'store']

Note that unless you need it to exist for some other reason, you don't even
have to have an actual "/Books" Folder for this code to work, and you could
leave out the 'manage' check.

Cheers,

Evan @ digicool & 4-am