Interesting problem with running a python script in a c wrapper.
Wayne Ringling
wayne at tbnets.com
Sun Sep 9 19:58:19 EDT 2001
I have been progressing on my project and ran into this little problem. I
have a script that is wrapped with the c wrapper from the python /Misc dir
and when I run it from my web server I get the error below: I show my
script first and then the error.
login.py--------------------------------------------------------------
#!/usr/bin/python
import config, keys, misc, shelve, anydbm
config = config.Confload()
encrypt_key = keys.generate_shortkey()
remote_ip = misc.grab_remoteip()
session_key_dbm = shelve.open(config.files.session_key_dbm, 'c')
session_key_dbm.close()
session_key_dbm = shelve.open(config.files.session_key_dbm)
session_key_dbm[encrypt_key] = remote_ip
print "Content-type: html/text\n\n"
print "<html><head></head><title>Test Page</title>"
print "<body>"
for key in session_key_dbm.keys():
print key, " -> ", session_key_dbm[key],"\n<br>"
print "</body></html>"
session_key_dbm.close()
login.py--------------------------------------------------------------------
/var/log/httpd/error_log----------------------------------------------------
Traceback (most recent call last):
File "/freesite-cgi/login.py", line 13, in ?
session_key_dbm = shelve.open(config.files.session_key_dbm)
File "/usr/lib/python2.0/shelve.py", line 157, in open
return DbfilenameShelf(filename, flag)
File "/usr/lib/python2.0/shelve.py", line 147, in __init__
Shelf.__init__(self, anydbm.open(filename, flag))
File "/usr/lib/python2.0/anydbm.py", line 86, in open
return mod.open(file, flag, mode)
File "/usr/lib/python2.0/dbhash.py", line 8, in open
return bsddb.hashopen(file, flag, mode)
bsddb.error: (21, 'Is a directory')
[Sun Sep 9 21:42:35 2001] [error] [client 216.181.182.140] Premature end of
script headers: /usr/local/httpd/cgi-bin/login
/var/log/httpd/error_log----------------------------------------------------
Now I know that "config.files.session_key_dbm" does =
"/usr/local/freesite/sessionkey_dbm"
It creates the dbm in the correct dir and then when it goes to read it. I
get the above error in my http server log. And the server sends a 500 error
to the web browser.
My server is a Suse 7.2 running Apache and mod_python. Not sure if this
info helps but you never know.
Btw the script works fine from the command line. Any Ideas?
Wayne
More information about the Python-list
mailing list