[Zope] set accessrule
Chris McDonough
chrism@zope.com
Thu, 21 Mar 2002 13:26:28 -0500
Hi,
I wouldn't bother to try to pass in REQUEST (the caller for access rules
does not pass any arguments in to the script). Instead, get the REQUEST
from context ala context.REQUEST. I think the test tab populates REQUEST
for you via magic that doesn't happen when an access rule is called.
Your script becomes:
-----------------------------------------
## Script (Python) "accessruleHB"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=
if context.REQUEST.SESSION.get('MySessionId') == None:
context.REQUEST.RESPONSE.redirect('/rootfolder')
-----------------------------------------
----- Original Message -----
From: <jbr@FIZ-Karlsruhe.DE>
To: <zope@zope.org>
Cc: <jbr@FIZ-Karlsruhe.DE>
Sent: Thursday, March 21, 2002 12:48 PM
Subject: [Zope] set accessrule
> Hello,
>
> I have difficulties with accessrule. I am using zope 2.5.0
>
> I have a folder named testfolder.
>
> For this folder I have set accessrule to the python script
> accessruleHB, which is in folder testfolder.
>
> -----------------------------------------
> ## Script (Python) "accessruleHB"
> ##bind container=container
> ##bind context=context
> ##bind namespace=
> ##bind script=script
> ##bind subpath=traverse_subpath
> ##parameters=REQUEST=None
> ##title=
> ##
> # Import a standard function, and get the HTML request and response
objects.
> # from Products.PythonScripts.standard import html_quote
>
> session = context.REQUEST.SESSION
>
> sessionId=session.get('MySessionId')
> if sessionId == None:
> REQUEST.RESPONSE.redirect('/rootfolder')
> -----------------------------------------
>
> But it seems that this script is not called automatically by
> set accessrules, because nothing happens.
>
> What I want is: If sombody is accessing folder testfolder, accessrule
> for this folder should call accessruleHB to redirect people (and thus
> to deny access) if they are not authorized.
>
> If I run the script standalone ( by calling it) it redirects to
rootfolder.
>
> What have I done wrong with setaccessrule ?
>
>
> With kind regards, Juergen Berger
>
> _______________________________________________
> Zope maillist - Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )
>