[Zope] Automatically login from a XRON method...
Josef Meile
jmeile@hotmail.com
Thu, 23 May 2002 20:23:35 +0200
This is a multi-part message in MIME format.
------=_NextPart_000_0044_01C20297.B6F8EF80
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi,=20
I just want to automatically login a user from a XRON Method
and then make some other things that because of the Zope
security restrictions can't be done as the "anonymous" user.
I've searched in the newsgroup but the only answers are by
using cookies.
I've tried the following code but it only works when I execute it
from a web browser:
<dtml-if expr=3D"portal_membership.isAnonymousUser()">
<dtml-call "RESPONSE.setCookie('__ac_name','myUser')">
<dtml-call "RESPONSE.setCookie('__ac_password','myPassword')">
<dtml-call "RESPONSE.redirect('myMethod')">
<dtml-else>
My code
</dtml-if>
This also:
External method:
def loginCronUser(self):
self.REQUEST.RESPONSE.setCookie('__ac_name','myUser')
self.REQUEST.RESPONSE.setCookie('__ac_password','myPassword')
But I always get the following error message:
Failed to trigger event.
Type=3Dbci.ServerError
Val=3D302 (File: Unknown Line: Unknown)
I guess the problem is that XRON Methods don't do that through a web
browser, so the cookie can't be set up.
Is there any other way of doing it?
Thanks in advanced,
Josef.
------=_NextPart_000_0044_01C20297.B6F8EF80
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2716.2200" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi, </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I just want to automatically login a =
user from a=20
XRON Method</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>and then make some other things that =
because of the=20
Zope</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>security restrictions </FONT><FONT =
face=3DArial=20
size=3D2>can't be done as the </FONT><FONT face=3DArial =
size=3D2>"anonymous"=20
user.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I've searched in the newsgroup but the =
only answers=20
are by</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>using cookies.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>I've tried the following code but it =
only works=20
when I execute it</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>from a web browser:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><dtml-if=20
expr=3D"portal_membership.isAnonymousUser()"></FONT></DIV>
<DIV><FONT face=3DArial size=3D2> <dtml-call=20
"RESPONSE.setCookie('__ac_name','myUser')"><BR> <dtml-call=20
"RESPONSE.setCookie('__ac_password','myPassword')"><BR> =
<dtml-call=20
"RESPONSE.redirect('myMethod')"><BR><dtml-else><BR> My=20
code</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></dtml-if></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial><FONT size=3D2>This also:</FONT></FONT></DIV>
<DIV><FONT face=3DArial><FONT =
size=3D2><FONT></FONT></FONT></FONT> </DIV>
<DIV><FONT face=3DArial><FONT size=3D2><FONT>External method:</DIV>
<DIV>def loginCronUser(self):<BR> =20
self.REQUEST.RESPONSE.setCookie('__ac_name','myUser')<BR> =20
self.REQUEST.RESPONSE.setCookie('__ac_password','myPassword')<BR></DIV>
<DIV></FONT></FONT></FONT><FONT face=3DArial><FONT size=3D2><FONT>But I =
always get=20
the following error message:</FONT></FONT></FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2><FONT>Failed to trigger=20
event.<BR>Type=3Dbci.ServerError<BR>Val=3D302 (File: Unknown Line:=20
Unknown)<BR></FONT></FONT></FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2><FONT>I guess the problem is that =
XRON=20
Methods don't do that through a web</FONT></FONT></FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2><FONT>browser, so the cookie =
can't be set=20
up.</FONT></FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial><FONT size=3D2>Is there any other way of doing=20
it?</FONT></FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2></FONT></FONT> </DIV>
<DIV><FONT face=3DArial><FONT size=3D2>Thanks in =
advanced,</FONT></FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2>Josef.</FONT></FONT><FONT=20
face=3DArial><FONT><FONT=20
size=3D2><FONT></DIV></FONT></FONT></FONT></FONT></BODY></HTML>
------=_NextPart_000_0044_01C20297.B6F8EF80--