[Zope-dev] SiteAccess improvements

Trevor Toenjes zope@toenjes.com
Sun, 25 Nov 2001 07:44:11 -0500


> What do you want to happen during traversal?
Evan's Embedded Session Values is his suggested use of SiteAccess2
http://www.zope.org/Members/4am/SiteAccess2/otheruse

I simply need to add a <dtml-var smallscript>(writing to a database) after a
valid SessionID is set.
However, 'smallscript' cannot be executed from the AccessRule because
security is not set yet.  The user gets a Zope login prompt and then a
    Site Error
    An error was encountered while publishing this resource.
    Unauthorized
    You are not authorized to access the_database

"AccessRule" with ***smallscript***
<dtml-let stack="REQUEST['TraversalRequestNameStack']">
Don't intercept management requests
<dtml-unless "stack[0][:6]=='manage'">
  Is the next path segment a positive integer?
  <dtml-if "_.int(stack[-1])>0">
    Save it and remove it from the path
    <dtml-call "REQUEST.set('SessionID', stack.pop())">
    Add it back into the logical path
    <dtml-call "REQUEST.setVirtualRoot(REQUEST.steps+[SessionID])">
*** <dtml-var smallscript> ***
  <dtml-else>
    <dtml-raise type="Invalid">Invalid Session ID!</dtml-raise>
  </dtml-if>
</dtml-unless>
</dtml-let>

For example purposes, this is 'smallscript':
<dtml-call
"the_database.setRow(sessID=_.render(SessionID), timestamp='time',
IP=_.render(REMOTE_ADDR))">

-Trevor