newbie form questions...

Sam Penrose spenrose at well.com
Mon Oct 8 12:40:03 EDT 2001


The data looks weird to you because you are pickling it. The pickle module 
exists so that you can save Python objects to file and then read them back in 
as Python objects. What you want to do is write to a regular file, something 
like:

output = open('/home/nemir/output/form.txt', 'w')
separator = '=' # or a space, or whatever you want
allFields = ['field1', 'field2', 'field3'] # ...etc....
for field in allFields:
    if form.has_key(field):
        line = separator.join([field, form[field].value])
        output.write(line)
        output.write('\n') #newline character
output.close()

..there are slicker ways to do it, but that's the basic idea.




More information about the Python-list mailing list