A General Handling of Form Data

This incoming handler does not replace CGI scripts but it obviates the need for many of them. If the page-generator needs the form itself, you need a CGI script. Otherwise, incoming should be sufficient.

If "incoming" is a key in the cgi.form, ming.cgi expects these keys in the form data:

It will use these USER CONSTS in Constants.py:

FILES contains name only, one on each line, no paths. If form's file is in FILES, ming.cgi reads up FILES_DIR+os.sep+file It then opens it for writing and writes a datestamp of the form

stamp|xxxxxxxxx.xxx
where the Xs are time in seconds converted to string, followed by
key|form[key].value()\n
for all keys but file, page, incoming, submit, and debug. (It only writes after testing sizes against INCOMING_MAX.) Then it writes "---\n" and closes the file.

Finally, it opens form["page"].value() in the client browser.

So, you can have a page with a form. It's incoming value triggers both the writing of the data and the triggering of the page which uses the data.

It is useful to have an empty dir with single-page subdirs for these page targets. I have, for example, /singles/thanks dir with a key file and a thankyou file. It thanks you for filling out a form and links back to a useful page.

Files are truncated at FILE_MAXLINES. So your code must handle abrupt truncation. I use try-except clauses.