[Tutor] CGI Video collection application File I/O troubles

Jacob S. keridee at jayco.net
Sun Dec 5 23:46:39 CET 2004

Your error message says that you are getting an empty string from your cgi
variable. I IMHO would suggest printing videodb['title'] before writing it
to a file to see what the variable contains. Or you might print out videodb
to see what the dictionary looks like. My off the wall guess is that 1) Your
cgi variables are not returning the value from the actual object that you
want 2) The script is running and assigning values to title, etc. before the
afore mentioned object is given a value. IOW, maybe you haven't assigned
values to the form before you try to read them.
Another suggestion. Comment out the file writing part and print everything
to the screen to verify that the output is what you want. "When in doubt,
print it out." - Jacob Schmidt


> Quoting "Jacob S." <keridee at jayco.net>:
> > Hi!
> >
> > Can I ask a few questions? (Other than this one...)
> > What output did you expect? A string, tuple, or what?
> A string output. When I create a dictionary variable from
> the python shell like this:
> videodb={'title':'Crash','year':'1996','director':'David Cronenberg'}
> and type in videodb['title'] afterwards python spits out the
> value 'Crash'. That's fine I get a string as expected.
> But when I try to write the value of videodb['title'] to
> a file nothing gets written.
> I hope I clarified the issue somewhat.
> > I'm not strong with
> > cgi stuff.
> > Also, you don't need the string module 1) because you don't use it 2)
> > because you can use string methods.
> >
> > Jacob Schmidt
> ok. I'll remove it. thanx.
> [snip]
> --
> The lady on the call box in Monkey Island 2
> Guybrush: I'm lost in the Inky Island Jungle in Monkey 2
> Lady: Just walk off the edge of the screen

More information about the Tutor mailing list