Python error: object does not support item or slice assignment
Hello, I want to write a login script which authentificates with a exUserFolder. But I get this error message: Zope has encountered an error while publishing this resource. Error Type: TypeError Error Value: object does not support item or slice assignment The Log says that the error is on line 5, marked with <--. ## Script (Python) "loginUser" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters=REQUEST=None ##title= ## if REQUEST == None: REQUEST = context.REQUEST RESPONSE = REQUEST.RESPONSE REQUEST['__ac_name'] = REQUEST['username'] <-- REQUEST['__ac_password'] = REQUEST['password'] try: # Login successfull. userObject = self.acl_users.validate(REQUEST) RESPONSE.redirect('loginok.zpt') except: # Login failed... authFailedCode=REQUEST.get('authFailedCode', '') RESPONSE.redirect('loginfailed.zpt?authFailedCode=%s'%(authFailedCode)) What is wrong? Thx, Florian
Florian Lindner wrote at 2003-9-26 13:46 +0200:
... Error Type: TypeError Error Value: object does not support item or slice assignment
The Log says that the error is on line 5, marked with <--. ... REQUEST['__ac_name'] = REQUEST['username'] <--
It is write: Use "REQUEST.set('__ac_name', REQUEST['username'])" Dieter
Dieter Maurer wrote:
Florian Lindner wrote at 2003-9-26 13:46 +0200:
... Error Type: TypeError Error Value: object does not support item or slice assignment
The Log says that the error is on line 5, marked with <--. ... REQUEST['__ac_name'] = REQUEST['username'] <--
It is write:
Use "REQUEST.set('__ac_name', REQUEST['username'])"
Thanks, the script works now. But I still can't login. I'm using exUserFolder and this script to login. Username and Password are right, but I'm always redirected to the error page. But can be wrong? thanks, Florian
Florian Lindner wrote:
Dieter Maurer wrote:
Florian Lindner wrote at 2003-9-26 13:46 +0200:
... Error Type: TypeError Error Value: object does not support item or slice assignment
The Log says that the error is on line 5, marked with <--. ... REQUEST['__ac_name'] = REQUEST['username'] <--
It is write:
Use "REQUEST.set('__ac_name', REQUEST['username'])"
Thanks, the script works now. But I still can't login. I'm using exUserFolder and this script to login. Username and Password are right, but I'm always redirected to the error page. But what can be wrong?
Ok, some more information I forgot. I want to login before the user requests a protected page. Just a login form to authentificate right away at the beginning of the site visit. Thanks, Florian
Florian Lindner wrote at 2003-9-27 00:35 +0200:
Dieter Maurer wrote:
Florian Lindner wrote at 2003-9-26 13:46 +0200:
... Use "REQUEST.set('__ac_name', REQUEST['username'])"
Thanks, the script works now. But I still can't login. I'm using exUserFolder and this script to login. Username and Password are right, but I'm always redirected to the error page. But can be wrong?
You may set the "__ac_name" too late to have any effect on authentication. Usually, authentication has already taken place when you get control; exception: AccessRules (or other "__before_publishing_traverse__" and "__bobo_traverse__" hooks). Dieter
Dieter Maurer wrote:
Florian Lindner wrote at 2003-9-27 00:35 +0200:
Dieter Maurer wrote:
Florian Lindner wrote at 2003-9-26 13:46 +0200:
... Use "REQUEST.set('__ac_name', REQUEST['username'])"
Thanks, the script works now. But I still can't login. I'm using exUserFolder and this script to login. Username and Password are right, but I'm always redirected to the error page. But can be wrong?
You may set the "__ac_name" too late to have any effect on authentication. Usually, authentication has already taken place when you get control; exception: AccessRules (or other "__before_publishing_traverse__" and "__bobo_traverse__" hooks).
I don't think so. The fact is that Zope doesn't even know that this is a log in page. It's a page to login BEFORE requesting protected content. So the first contact with Zope authentification is on userObject = self.acl_users.validate(REQUEST) And there obviously an error occurs. I hope I could explain what I mean... ;-) thx, Florian
Florian Lindner wrote at 2003-9-27 13:55 +0200:
Dieter Maurer wrote: ...
You may set the "__ac_name" too late to have any effect on authentication. Usually, authentication has already taken place when you get control; exception: AccessRules (or other "__before_publishing_traverse__" and "__bobo_traverse__" hooks).
I don't think so. The fact is that Zope doesn't even know that this is a log in page. It's a page to login BEFORE requesting protected content. So the first contact with Zope authentification is on userObject = self.acl_users.validate(REQUEST)
Zope does the authentication even for non-protected content. When there is not authentication info, the result will be the "Anonymous user". Dieter
participants (3)
-
Dieter Maurer -
Florian Lindner -
Florian Lindner