473,320 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Python CGI

I need to update a CGI script I have been working on to perform
validation of input files. The basic idea is this:

1.) HTML page is served
2.) User posts file and some other info
3.) Check file for necessary data
* If data is missing, then post a 2nd page requesting needed data
* If data is present, continue to 4
4.) Process input file and display results (processing path depends on
whether data from 3 was present in file or had to be input by user)

I'm unsure of the best way to implement step 3. Is it even possible to
put all of this into one script? Or should I have one script check the
file for the data, then pass the info on to a 2nd script? The
cgi.FieldStorage() function should only be called once, so it seems
like it's not possible to read a form and then repost another one and
read it. If this is true and I need 2 scripts, how do I pass on the
information in step 3 automatically if the file has the proper data and
no user input is needed?

Sorry if this is a dumb question (or unclear), but this is my
(ever-growing) first CGI script. Thanks.
Jeremy

Dec 1 '05 #1
3 1196
"jbrewer" <je*************@gmail.com> wrote:

I need to update a CGI script I have been working on to perform
validation of input files. The basic idea is this:

1.) HTML page is served
2.) User posts file and some other info
3.) Check file for necessary data
* If data is missing, then post a 2nd page requesting needed data
* If data is present, continue to 4
4.) Process input file and display results (processing path depends on
whether data from 3 was present in file or had to be input by user)

I'm unsure of the best way to implement step 3. Is it even possible to
put all of this into one script? Or should I have one script check the
file for the data, then pass the info on to a 2nd script? The
cgi.FieldStorage() function should only be called once, so it seems
like it's not possible to read a form and then repost another one and
read it. If this is true and I need 2 scripts, how do I pass on the
information in step 3 automatically if the file has the proper data and
no user input is needed?


Each web transaction standsalone. User sends request, you send reply, your
CGI process ends. Every new request is another run.

So, you can either use one script per operation, or you can use one script
and detect which step it is using, for example a hidden field.

If you need common file processing in both scripts, I'm sure you already
know you can put that code in a separate Python file and import it into the
two CGI scripts.
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Dec 1 '05 #2
That doesn't sound too difficult to do in a single script.

As Tim has mentioned, you can always separate the code in two modules
and just import the one needed for the action being performed.

Your script just needs to output different HTML depending on the result
- with a different form depending on what information is required.

All the best,

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml

Dec 1 '05 #3
Thanks guys. I didn't realize that hidden form fields were so easy to
use.

Jeremy

Dec 1 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.