I'm trying to use FormServlet in a small web chat application.
There I get the following error:
ERROR: Python Exception
ERROR: Traceback (innermost last):
ERROR: File "C:\Python24\lib\site-packages\netsvc\__init__.py", line 2531, in processRequest
ERROR: form = cgi.FieldStorage(headers=headers,environ=environ,
ERROR: exceptions.NameError: global name 'cgi' is not defined
IMHO the problem are those 2 lines in FormServlet:
2514 global cgi,StringIO
2515 import cgi,StringIO
When I import cgi and StringIO normally in the module it works.
My environment: Win2000 / ActivePython 2.4 Build 243
Thanks a lot in advance!
Marcel
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I know why I probably didn't import them at global scope and tried to defer them to when required. That is because "cgi" module can seem to take a long time to import on some platforms for some reason.
Suggesting getting rid of the "global" line and moving the import into the processRequest() below that point where they are actually used. Although, then should possibly do the import in processContent() as well.
Am I being to paranoid about speed of import of "cgi" module.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all!
I'm trying to use FormServlet in a small web chat application.
There I get the following error:
ERROR: Python Exception
ERROR: Traceback (innermost last):
ERROR: File "C:\Python24\lib\site-packages\netsvc\__init__.py", line 2531, in processRequest
ERROR: form = cgi.FieldStorage(headers=headers,environ=environ,
ERROR: exceptions.NameError: global name 'cgi' is not defined
IMHO the problem are those 2 lines in FormServlet:
2514 global cgi,StringIO
2515 import cgi,StringIO
When I import cgi and StringIO normally in the module it works.
My environment: Win2000 / ActivePython 2.4 Build 243
Thanks a lot in advance!
Marcel
Hmmm, that line:
global cgi,StringIO
looks decidely bogus. Not sure why I did that.
I know why I probably didn't import them at global scope and tried to defer them to when required. That is because "cgi" module can seem to take a long time to import on some platforms for some reason.
Suggesting getting rid of the "global" line and moving the import into the processRequest() below that point where they are actually used. Although, then should possibly do the import in processContent() as well.
Am I being to paranoid about speed of import of "cgi" module.