Interesting problem with running a python script in a c wrapper.

Wayne Ringling wayne at
Mon Sep 10 01:58:19 CEST 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.


import config, keys, misc, shelve, anydbm

config = config.Confload()
encrypt_key = keys.generate_shortkey()
remote_ip = misc.grab_remoteip()

session_key_dbm =, 'c')

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>"


Traceback (most recent call last):
  File "/freesite-cgi/", line 13, in ?
    session_key_dbm =
  File "/usr/lib/python2.0/", line 157, in open
    return DbfilenameShelf(filename, flag)
  File "/usr/lib/python2.0/", line 147, in __init__
    Shelf.__init__(self,, flag))
  File "/usr/lib/python2.0/", line 86, in open
    return, flag, mode)
  File "/usr/lib/python2.0/", 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] Premature end of
script headers: /usr/local/httpd/cgi-bin/login

Now I know that "config.files.session_key_dbm" does =

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?


More information about the Python-list mailing list