Seite 1 von 1

Python-CGIServer: Fehler beim schreiben von Cookies :(

Verfasst: Dienstag 13. September 2005, 21:02
von jens
Hab ein zimlich komisches Problem mit meinem PyLucid Standalone:
Exception happened during processing of request from ('127.0.0.1', 1923)
Traceback (most recent call last):
File "D:\Python\Python24\lib\SocketServer.py", line 222, in handle_request
self.process_request(request, client_address)
File "D:\Python\Python24\lib\SocketServer.py", line 241, in process_request
self.finish_request(request, client_address)
File "D:\Python\Python24\lib\SocketServer.py", line 254, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "D:\Python\Python24\lib\SocketServer.py", line 521, in __init__
self.handle()
File "D:\Python\Python24\lib\BaseHTTPServer.py", line 314, in handle
self.handle_one_request()
File "D:\Python\Python24\lib\BaseHTTPServer.py", line 308, in handle_one_reque
st
method()
File "D:\Python\Python24\lib\CGIHTTPServer.py", line 59, in do_POST
self.run_cgi()
File "D:\Python\Python24\lib\CGIHTTPServer.py", line 295, in run_cgi
execfile(scriptfile, {"__name__": "__main__"})
File "W:\PyLucid_tarball\index.py", line 671, in ?
page_content = LucidRender().make()
File "W:\PyLucid_tarball\index.py", line 210, in __init__
self.session = sessionhandling.sessionhandler( self.PyLucid, page_msg
_debug=True )
File "W:\PyLucid_tarball\PyLucid_system\sessionhandling.py", line 143, in __in
it__

File "W:\PyLucid_tarball\PyLucid_system\sessionhandling.py", line 169, in dete
ctSession
msg = "error;no client cookie found."
File "W:\PyLucid_tarball\PyLucid_system\sessionhandling.py", line 298, in dele
teCookie

File "W:\PyLucid_tarball\PyLucid_system\sessionhandling.py", line 295, in writ
eCookie

File "D:\Python\Python24\lib\socket.py", line 256, in write
self.flush()
File "D:\Python\Python24\lib\socket.py", line 243, in flush
self._sock.sendall(buffer)
error: (10053, 'Software caused connection abort')
Das ganze passiert beim versuch sich einzuloggen... Dabei wird eigentlich die User-Daten überprüft und ein Cookie geschrieben... Dabei scheint aber Python's CGI-Server probleme zu machen...

Mit einem kleinen mini CGI-Skript kann ich allerdings schon normal Cookies schreiben?!?!

Verfasst: Mittwoch 14. September 2005, 15:37
von mitsuhiko
Moin Moin,

Bei dir dreht sich wohl alles um pyLucid ;-)
Kann es sein, dass der Server dort einfach keine Schreibrechte hat? Ich meine irgendwo muss doch PyLucid die Session Informationen ablegen.
Bzw: Wie geht pyLucid da vor?

Verfasst: Mittwoch 14. September 2005, 15:40
von jens
Also ich glaube der Fehler lag ehr am CGIServer... Mit der neuen Variante gibt es keine Probleme mit Cookies, dafür aber andere Schwirigkeiten: http://www.python-forum.de/viewtopic.php?p=23576#23576

Verfasst: Mittwoch 14. September 2005, 16:30
von jens
Korrektur! Ich weiß nun, das es auch mit dem Abfragen der FieldStorage zu tun hat!

Ich hab nun mal ein kleines Test-Skript gebaut und den Fehler genau untersucht:

Code: Alles auswählen

#!/usr/bin/python
# -*- coding: UTF-8 -*-

import cgi

print "Content-type: text/html; charset=utf-8\r\n"
#~ print "OK"

print cgi.FieldStorage()
print cgi.FieldStorage() # zweites mal abfragen

print """<form name="login" method="post" action="?page_id=1&command=auth&action=check_login">
User: <input name="user" type="text" value=""><button type="submit">ab!</button>
</form>"""
Er tritt immer dann auf, wenn ich die cgi.FieldStorage() ein zweites mal abfrage?!?!?
Mit apache ist das überhaupt kein Problem...

Kann das einer nachvollziehen??? Ich denke das ist das ein Bug, was? Ich werde es jetzt mal mit der kleinsten Variante eines Python CGI-Server's probieren.

EDIT: HA :shock: Mit einem unmodifizieren Server geht's:

Code: Alles auswählen

#!/usr/bin/python
# -*- coding: UTF-8 -*-

import BaseHTTPServer, CGIHTTPServer

s = BaseHTTPServer.HTTPServer( ("" ,80) ,CGIHTTPServer.CGIHTTPRequestHandler)
s.serve_forever()