On 8/7/05, gordnjen <[EMAIL PROTECTED]> wrote:
> 
> I am now stuck again. I am at my wit's end. The course I am taking is a
> supposed "beginners" course. It is a distance education class, and our
> textbook does NOT contain the information required to do all of the
> assignments (perhaps it was designed for people with more experience and/or
> knowledge?). Anyways, our latest assignment is that we have to create a
> working chequebook (view here:
> http://cmpt165.cs.sfu.ca/~ggbaker/examples/chequebook.html)
> 
> This is what I have so far (see attached).
> 
> I am so completely lost.
> 
> Our textbook does not tell us how to implement a password security system on
> a website, or how to store data.
> 
> The project is already over a week late, and I feel absolutely hopeless
> about it.
> 
> Could you possibly give me some pointers on this? Please, please please?
> 
> Thank you in advance,
> 
> Jennine Gates
> 

Hi Jennine,

To complete this assignment you will be writing a CGI. From the
website it appears that you have not had to write one before that used
form data. To use form data with python, you should use the cgi
module. You can examine the documentation for this module by pressing
F1 while within IDLE, and entering the module list.

Here's a simple example:

#!/usr/LOCAL/bin/python

print "Content-type: text/html\n\n"

import cgi

def main(form):
    if form.has_key("Name"):
        print "<p>Name: %s</p>" % form["Name"].value
    else:
        print """<form
action="http://cgi.sfu.ca/~rbnewby/cgi-bin/example.cgi"; method="get">
                     <input type="text" name="Name" value="Jennine" />
                     <input type="submit" value="submit">
                 </form>"""

if __name__ == "__main__":
    main(cgi.FieldStorage())


A working example is viewable at: 

http://cgi.sfu.ca/~rbnewby/cgi-bin/example.cgi


Depending upon the requirements of the assignment you may be able to
password protect the script with htauth, details here:

http://www.sfu.ca/acs/sfuwebhelp/htaccess.htm

Cheers,

Luis
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to