[Zope] set accessrule

jbr@FIZ-Karlsruhe.DE jbr@FIZ-Karlsruhe.DE
Thu, 21 Mar 2002 22:17:59 +0100 (MET)


Dear Chris,

it is working.

Thank you very much for your help.

With kind regards, Juergen


 > From chrism@zope.com Thu Mar 21 19:21 MET 2002
 > Subject: Re: [Zope] set accessrule
 > Date: 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
 > >