cgi.FieldStorage() does not list POST, nor GET variables

"Tom Van Acker" <[email protected]>
Newsgroups gmane.comp.python.mod_python
Organization OR-AS
Message-ID <4CA46D6FA76D45AEBB99AFBAF7B6AF91@HPTom>
Dear All,

Recently, we moved an application to a server running Linux/SUSE, apache 2.2.4, with mod_python 3.3.1. 
In the attachment, I included the output from the testhandler (as described in http://www.modpython.org/live/current/doc-html/inst-trouble.html).

This application worked perfect before, but now, for some strange reason, nothing works anymore. 
I spent a whole day investigating this problem, but now I'm stuck. 
It seems like form variables are simply not passed to the python scripts. I tried using GET or POST  methods, 
I tried the cgihandler and the publisher .... nothing helps. 

I'm using cgi.FieldStorage() to get to the form variables, but the result is empty, no matter what I do. 

This is how the apache configuration looks;

<Directory /srv/www/htdocs/>
  Options ExecCGI FollowSymLinks
  AllowOverride None
  Order allow,deny
  allow from all
  SetHandler mod_python
  PythonHandler mod_python.cgihandler
  PythonDebug On
</Directory>

A very simple python program I used for testing looks like this; 

#!/usr/bin/python

import cgi

form = cgi.FieldStorage()

str=('%d ' % (len(form.keys())))
for name in form.keys():
    str=str+"Input: " + name + " value: " + form[name].value + "<BR>"

str=str+"Finished!"

print "Content-Type: text/html\n\n"
print str

The ouput simply is "0 Finished". 
I'm really stuck, I'm afraid. Any help is greatly appreciated. 

Thanks in advance,
Tom

_______________________________________________
Mod_python mailing list
[email protected]
http://mailman.modpython.org/mailman/listinfo/mod_python
mod_python test page.htm (text/html, 12.1 KB)
<html><head><title>mod_python test page</title></head><body>
<h3>General information</h3>
<table border="1">
<tr><td><code>Apache version</code></td><td><code>Apache/2.2.4 (Linux/SUSE)</code></td></tr>
<tr><td><code>Apache threaded MPM</code></td><td><code>No (single thread MPM)</code></td></tr>
<tr><td><code>Apache forked MPM</code></td><td><code>Yes, maximum 150 processes</code></td></tr>
<tr><td><code>Apache server root</code></td><td><code>/srv/www</code></td></tr>
<tr><td><code>Apache document root</code></td><td><code>/srv/www/htdocs/</code></td></tr>
<tr><td><code>Apache error log</code></td><td><code>/var/log/apache2/error_log</code> (<a href="?view_log=1" target="_new">view last 100 lines</a>)</td></tr>
<tr><td><code>Python sys.version</code></td><td><code>2.5.1 (r251:54863, Sep 22 2007, 01:43:31) 
[GCC 4.2.1 (SUSE Linux)]</code></td></tr>
<tr><td><code>Python sys.path</code></td><td><pre>/usr/lib/python25.zip
/usr/lib/python2.5
/usr/lib/python2.5/plat-linux2
/usr/lib/python2.5/lib-tk
/usr/lib/python2.5/lib-dynload
/usr/lib/python2.5/site-packages
/usr/lib/python2.5/site-packages/Numeric
/usr/lib/python2.5/site-packages/gtk-2.0
/srv/www/htdocs/EvaStLucas/python</pre></td></tr>
<tr><td><code>Python interpreter name</code></td><td><code>193.190.145.166</code></td></tr>
<tr><td><code>mod_python.publisher available</code></td><td><code>Yes</code></td></tr>
<tr><td><code>mod_python.psp available</code></td><td><code>Yes</code></td></tr>
</table>
<h3>Request input headers</h3>
<table border="1"><tr><th>Key</th><th>Value</th></tr>
<tr><td><code>Accept</code></td><td><code>*/*</code></td></tr>
<tr><td><code>Accept-Language</code></td><td><code>nl-be</code></td></tr>
<tr><td><code>UA-CPU</code></td><td><code>x86</code></td></tr>
<tr><td><code>Accept-Encoding</code></td><td><code>gzip, deflate</code></td></tr>
<tr><td><code>User-Agent</code></td><td><code>Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; GTB5; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 1.1.4322; .NET CLR 3.0.30618)</code></td></tr>
<tr><td><code>Host</code></td><td><code>193.190.145.166:8080</code></td></tr>
<tr><td><code>Connection</code></td><td><code>Keep-Alive</code></td></tr>
</table><h3>Request environment</h3>
<table border="1"><tr><th>Key</th><th>Value</th></tr>
<tr><td><code>GATEWAY_INTERFACE</code></td><td><code>CGI/1.1</code></td></tr>
<tr><td><code>SERVER_PROTOCOL</code></td><td><code>HTTP/1.1</code></td></tr>
<tr><td><code>REQUEST_METHOD</code></td><td><code>GET</code></td></tr>
<tr><td><code>QUERY_STRING</code></td><td><code>test=d</code></td></tr>
<tr><td><code>REQUEST_URI</code></td><td><code>/mpinfo?test=d</code></td></tr>
<tr><td><code>SCRIPT_NAME</code></td><td><code>/mpinfo</code></td></tr>
<tr><td><code>HTTP_ACCEPT</code></td><td><code>*/*</code></td></tr>
<tr><td><code>HTTP_ACCEPT_LANGUAGE</code></td><td><code>nl-be</code></td></tr>
<tr><td><code>HTTP_UA_CPU</code></td><td><code>x86</code></td></tr>
<tr><td><code>HTTP_ACCEPT_ENCODING</code></td><td><code>gzip, deflate</code></td></tr>
<tr><td><code>HTTP_USER_AGENT</code></td><td><code>Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; GTB5; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 1.1.4322; .NET CLR 3.0.30618)</code></td></tr>
<tr><td><code>HTTP_HOST</code></td><td><code>193.190.145.166:8080</code></td></tr>
<tr><td><code>HTTP_CONNECTION</code></td><td><code>Keep-Alive</code></td></tr>
<tr><td><code>PATH</code></td><td><code>/sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib/jvm/jre/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin</code></td></tr>
<tr><td><code>SERVER_SIGNATURE</code></td><td><code><address>Apache/2.2.4 (Linux/SUSE) Server at 193.190.145.166 Port 8080</address>
</code></td></tr>
<tr><td><code>SERVER_SOFTWARE</code></td><td><code>Apache/2.2.4 (Linux/SUSE)</code></td></tr>
<tr><td><code>SERVER_NAME</code></td><td><code>193.190.145.166</code></td></tr>
<tr><td><code>SERVER_ADDR</code></td><td><code>193.190.145.166</code></td></tr>
<tr><td><code>SERVER_PORT</code></td><td><code>8080</code></td></tr>
<tr><td><code>REMOTE_ADDR</code></td><td><code>10.5.1.7</code></td></tr>
<tr><td><code>DOCUMENT_ROOT</code></td><td><code>/srv/www/htdocs/</code></td></tr>
<tr><td><code>SERVER_ADMIN</code></td><td><code>[no address given]</code></td></tr>
<tr><td><code>SCRIPT_FILENAME</code></td><td><code>/srv/www/htdocs/mpinfo</code></td></tr>
<tr><td><code>REMOTE_PORT</code></td><td><code>22813</code></td></tr>
</table><h3>Request configuration</h3>
<table border="1"><tr><th>Key</th><th>Value</th></tr>
<tr><td><code>PythonPath</code></td><td><code>sys.path+['/srv/www/htdocs/EvaStLucas/python']</code></td></tr>
<tr><td><code>PythonDebug</code></td><td><code>1</code></td></tr>
</table><h3>Request options</h3>
<table border="1"><tr><th>Key</th><th>Value</th></tr>
</table><h3>Request notes</h3>
<table border="1"><tr><th>Key</th><th>Value</th></tr>
<tr><td><code>python_init_ran</code></td><td><code>1</code></td></tr>
</table><h3>Server configuration</h3>
<table border="1"><tr><th>Key</th><th>Value</th></tr>
</table><h3>Server options</h3>
<table border="1"><tr><th>Key</th><th>Value</th></tr>
</table><h3>Server configuration tree</h3>
<pre>User wwwrun
Group www
StartServers 5
MinSpareServers 5
MaxSpareServers 10
ServerLimit 150
MaxClients 150
MaxRequestsPerChild 10000
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
BrowserMatch "RealPlayer 4\.0" force-response-1.0
BrowserMatch "Java/1\.0" force-response-1.0
BrowserMatch "JDK/1\.0" force-response-1.0
BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
BrowserMatch "^WebDrive" redirect-carefully
BrowserMatch "^WebDAVFS/1.[012]" redirect-carefully
BrowserMatch "^gnome-vfs" redirect-carefully
ErrorLog /var/log/apache2/error_log
Listen 8080
LogFormat "%h %l %u %t \"%r\" %>s %b"			common
LogFormat "%v %h %l %u %t \"%r\" %>s %b"		vhost_common
LogFormat "%{Referer}i -> %U"				referer
LogFormat "%{User-agent}i"				agent
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""			combined
LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""			vhost_combined
Logformat "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"						ssl_common
Logformat "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b \"%{Referer}i\" \"%{User-Agent}i\""		ssl_combined
Timeout 300
ServerSignature on
UseCanonicalName off
ServerTokens OS
LogLevel warn
CustomLog /var/log/apache2/access_log combined
IndexOptions FancyIndexing VersionSort NameWidth=*
AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip
AddIconByType (TXT,/icons/text.gif) text/*
AddIconByType (IMG,/icons/image2.gif) image/*
AddIconByType (SND,/icons/sound2.gif) audio/*
AddIconByType (VID,/icons/movie.gif) video/*
AddIcon /icons/binary.gif .bin .exe
AddIcon /icons/binhex.gif .hqx
AddIcon /icons/tar.gif .tar
AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
AddIcon /icons/a.gif .ps .ai .eps
AddIcon /icons/layout.gif .html .shtml .htm .pdf
AddIcon /icons/text.gif .txt
AddIcon /icons/c.gif .c
AddIcon /icons/p.gif .pl .py
AddIcon /icons/f.gif .for
AddIcon /icons/dvi.gif .dvi
AddIcon /icons/uuencoded.gif .uu
AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
AddIcon /icons/tex.gif .tex
AddIcon /icons/bomb.gif core
AddIcon /icons/back.gif ..
AddIcon /icons/hand.right.gif README
AddIcon /icons/folder.gif ^^DIRECTORY^^
AddIcon /icons/blank.gif ^^BLANKICON^^
DefaultIcon /icons/unknown.gif
ReadmeName README.html
HeaderName HEADER.html
IndexIgnore .??* *~ *# HEADER* RCS CVS *,v *,t
TypesConfig /etc/apache2/mime.types
DefaultType text/plain
AddLanguage ca .ca
AddLanguage cs .cz .cs
AddLanguage da .dk
AddLanguage de .de
AddLanguage el .el
AddLanguage en .en
AddLanguage eo .eo
AddLanguage es .es
AddLanguage et .et
AddLanguage fr .fr
AddLanguage he .he
AddLanguage hr .hr
AddLanguage it .it
AddLanguage ja .ja
AddLanguage ko .ko
AddLanguage ltz .ltz
AddLanguage nl .nl
AddLanguage nn .nn
AddLanguage no .no
AddLanguage pl .po
AddLanguage pt .pt
AddLanguage pt-BR .pt-br
AddLanguage ru .ru
AddLanguage sv .sv
AddLanguage zh-CN .zh-cn
AddLanguage zh-TW .zh-tw
LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW
ForceLanguagePriority Prefer Fallback
AddCharset ISO-8859-1  .iso8859-1  .latin1
AddCharset ISO-8859-2  .iso8859-2  .latin2 .cen
AddCharset ISO-8859-3  .iso8859-3  .latin3
AddCharset ISO-8859-4  .iso8859-4  .latin4
AddCharset ISO-8859-5  .iso8859-5  .latin5 .cyr .iso-ru
AddCharset ISO-8859-6  .iso8859-6  .latin6 .arb
AddCharset ISO-8859-7  .iso8859-7  .latin7 .grk
AddCharset ISO-8859-8  .iso8859-8  .latin8 .heb
AddCharset ISO-8859-9  .iso8859-9  .latin9 .trk
AddCharset ISO-2022-JP .iso2022-jp .jis
AddCharset ISO-2022-KR .iso2022-kr .kis
AddCharset ISO-2022-CN .iso2022-cn .cis
AddCharset Big5        .Big5       .big5
AddCharset WINDOWS-1251 .cp-1251   .win-1251
AddCharset CP866       .cp866
AddCharset KOI8-r      .koi8-r .koi8-ru
AddCharset KOI8-ru     .koi8-uk .ua
AddCharset ISO-10646-UCS-2 .ucs2
AddCharset ISO-10646-UCS-4 .ucs4
AddCharset UTF-8       .utf8
AddCharset GB2312      .gb2312 .gb
AddCharset utf-7       .utf7
AddCharset utf-8       .utf8
AddCharset big5        .big5 .b5
AddCharset EUC-TW      .euc-tw
AddCharset EUC-JP      .euc-jp
AddCharset EUC-KR      .euc-kr
AddCharset shift_jis   .sjis
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
Addtype image/x-icon .ico
AddHandler type-map var
Alias /error/ "/usr/share/apache2/error/"
<Directory "/usr/share/apache2/error">
    AllowOverride None
    Options IncludesNoExec
    AddOutputFilter Includes html
    AddHandler type-map var
    Order allow,deny
    Allow from all
    LanguagePriority en cs de es fr it ja ko nl pl pt-br ro sv tr
    ForceLanguagePriority Prefer Fallback
ErrorDocument 400 /error/HTTP_BAD_REQUEST.html.var
ErrorDocument 401 /error/HTTP_UNAUTHORIZED.html.var
ErrorDocument 403 /error/HTTP_FORBIDDEN.html.var
ErrorDocument 404 /error/HTTP_NOT_FOUND.html.var
ErrorDocument 405 /error/HTTP_METHOD_NOT_ALLOWED.html.var
ErrorDocument 408 /error/HTTP_REQUEST_TIME_OUT.html.var
ErrorDocument 410 /error/HTTP_GONE.html.var
ErrorDocument 411 /error/HTTP_LENGTH_REQUIRED.html.var
ErrorDocument 412 /error/HTTP_PRECONDITION_FAILED.html.var
ErrorDocument 413 /error/HTTP_REQUEST_ENTITY_TOO_LARGE.html.var
ErrorDocument 414 /error/HTTP_REQUEST_URI_TOO_LARGE.html.var
ErrorDocument 415 /error/HTTP_UNSUPPORTED_MEDIA_TYPE.html.var
ErrorDocument 500 /error/HTTP_INTERNAL_SERVER_ERROR.html.var
ErrorDocument 501 /error/HTTP_NOT_IMPLEMENTED.html.var
ErrorDocument 502 /error/HTTP_BAD_GATEWAY.html.var
ErrorDocument 503 /error/HTTP_SERVICE_UNAVAILABLE.html.var
ErrorDocument 506 /error/HTTP_VARIANT_ALSO_VARIES.html.var
<Directory />
    Options None
    AllowOverride None
    Order deny,allow
    Deny from all
AccessFileName .htaccess
<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
DirectoryIndex index.html index.html.var
DocumentRoot "/srv/www/htdocs/"
<Directory "/srv/www/htdocs/">
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
Alias /icons/ "/usr/share/apache2/icons/"
<Directory "/usr/share/apache2/icons">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
ScriptAlias /cgi-bin/ "/srv/www/cgi-bin/"
<Directory "/srv/www/cgi-bin">
    AllowOverride None
    Options +ExecCGI -Includes
    Order allow,deny
    Allow from all
UserDir public_html
UserDir disabled root
<Directory /home/*/public_html>
    AllowOverride FileInfo AuthConfig Limit Indexes
    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
    <Limit GET POST OPTIONS PROPFIND>
        Order allow,deny
        Allow from all
    <LimitExcept GET POST OPTIONS PROPFIND>
        Order deny,allow
        Deny from all
<Directory /srv/www/htdocs/>
    Options ExecCGI FollowSymLinks
    AllowOverride None
    Order allow,deny
    allow from all
    SetHandler mod_python
    PythonPath "sys.path+['/srv/www/htdocs/EvaStLucas/python']"
    PythonHandler mod_python.publisher
    PythonDebug On
<Location /mpinfo>
    SetHandler mod_python
    PythonHandler mod_python.testhandler
</pre>
</body></html>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.