Newb - web portal for Unix tool

Bob Arens martian_bob at portalofevil.com
Thu Sep 26 18:17:28 EDT 2002


Hiyo, total newbie to Python though not HTML, etc. I'm writing a web-based 
portal allowing users to use Expat by entering their XML into a form.

The HTML is trivial - just a text area and submit button. I'm using a 
pretty good reference for the CGI bit (Internet Programming with Python by 
Watters, van Rossum and Ahlstrom), but their examples don't seem to be 
working for me. So here are my big questions:

1. How do I write out input from a text area to a file?
2. How do I make a command line call from within a CGI script?
3. How can I debug my script?

Here (more or less) is what I have for the script (where METHOD="POST" and 
TEXTAREA NAME="XMLin" in the HTML, and testme.xml is the file I'm writing 
to)
----------------------------
import genCGI, string

class ExPortal(genCGI.ParseMixin, genCGI.Verbose_Mixin, genCGI.cgiBase):
    	MultiValuedFields = ["XMLin"]

def success(self):
    	items = self.formdict.items()
    	items = map(str, items)
    	items = string.joinfields(items)
    	outfile = open("testme.xml")
    	outfile.write(items)
    	outfile.close()

if __name__=="__main__":
    	ExPortal().GO()
-----------------------------

Any help is much appreciated!



More information about the Python-list mailing list