Trouble with CGI code from Code Example 7.3 of the "Python Interactive CGI Tutorial"

Discussion in 'Python' started by epsilon, Aug 21, 2007.

  1. epsilon

    epsilon Guest

    Hey gang!

    I'm having trouble with this script from a CGI lesson I'm working and
    I can't seem to figure it out. I was wondering if someone could tell
    me what is wrong. I've spent several hours trying to debug, but no
    success. Any help would be appreciated.

    Thank you,
    Christopher

    +++++

    Python Interactive CGI Tutorial - Code Example 7.3
    http://www.cs.virginia.edu/~lab2q/lesson_7/

    # Define function display_page.
    def display_page(result, id, session_key = 0):
    print "<HTML>\n"
    print "<HEAD>\n"
    print "\t<TITLE>Info Form</TITLE>\n"
    print "</HEAD>\n"
    print "<BODY BGCOLOR = white>\n"
    if (result == "passed"):
    if (session_key == 0):
    session_key = create_session(id)
    print id, , you are logged in with key:", session_key,
    "\n"
    print "\t\t<FORM METHOD = post ACTION = \
    \"example_7.3.cgi\">\n"
    print "\t\t<INPUT TYPE = \"hidden\" NAME = \
    \"session_key\" VALUE =\", session_key, ">\n"
    print "\t\t<INPUT TYPE = \"submit\" \
    VALUE = \"Stay Logged In.\"></FORM>\n"
    print "\t\t<FORM METHOD = post ACTION = \
    \"example_7.3.cgi\">\n"
    print "\t\t<INPUT TYPE = \"hidden\" NAME = \
    \"session_key\" VALUE =", session_key, ">\n"
    print "\t\t<INPUT TYPE = \"hidden\" NAME =\
    \"logout\" VALUE = \"logout\" >\n"
    print "\t\t<INPUT TYPE = \"submit\" \
    VALUE = \"Logout.\"></FORM>\n"
    else:
    print "You entered the incorrect combo.\n"
    print "</BODY>\n"
    print "</HTML>\n"
     
    epsilon, Aug 21, 2007
    #1
    1. Advertising

  2. On 21 ago, 11:14, epsilon <> wrote:

    > I'm having trouble with this script from a CGI lesson I'm working and
    > I can't seem to figure it out. I was wondering if someone could tell
    > me what is wrong. I've spent several hours trying to debug, but no
    > success. Any help would be appreciated.


    Next time try to post the exact error message you get - working
    crystall balls are hard to find nowadays :)
    Ok, it's a syntax error, perhaps you didn't get a useful response from
    the server.
    The error is here:

    > if (session_key == 0):
    > session_key = create_session(id)
    > print id, , you are logged in with key:", session_key,


    That should read:

    print id, "you are logged in with key:", session_key, "\n"

    --
    Gabriel Genellina
     
    Gabriel Genellina, Aug 21, 2007
    #2
    1. Advertising

  3. epsilon

    epsilon Guest

    Gabriel,

    Thanks a bunch for your time! That took care of it.

    Christopher


    Gabriel Genellina wrote:
    > On 21 ago, 11:14, epsilon <> wrote:
    >
    > > I'm having trouble with this script from a CGI lesson I'm working and
    > > I can't seem to figure it out. I was wondering if someone could tell
    > > me what is wrong. I've spent several hours trying to debug, but no
    > > success. Any help would be appreciated.

    >
    > Next time try to post the exact error message you get - working
    > crystall balls are hard to find nowadays :)
    > Ok, it's a syntax error, perhaps you didn't get a useful response from
    > the server.
    > The error is here:
    >
    > > if (session_key == 0):
    > > session_key = create_session(id)
    > > print id, , you are logged in with key:", session_key,

    >
    > That should read:
    >
    > print id, "you are logged in with key:", session_key, "\n"
    >
    > --
    > Gabriel Genellina
     
    epsilon, Aug 21, 2007
    #3
  4. epsilon

    Steve Holden Guest

    Re: Trouble with CGI code from Code Example 7.3 of the "PythonInteractive CGI Tutorial"

    Gabriel Genellina wrote:

    [...]working crystall balls are hard to find nowadays :)

    Well, judging by the OP's response you appear to be in possession of a
    pair :)

    regards
    Steve
    --
    Steve Holden +1 571 484 6266 +1 800 494 3119
    Holden Web LLC/Ltd http://www.holdenweb.com
    Skype: holdenweb http://del.icio.us/steve.holden
    --------------- Asciimercial ------------------
    Get on the web: Blog, lens and tag the Internet
    Many services currently offer free registration
    ----------- Thank You for Reading -------------
     
    Steve Holden, Aug 22, 2007
    #4
  5. On 21 ago, 20:10, Steve Holden <> wrote:
    > Gabriel Genellina wrote:
    >
    > [...]working crystall balls are hard to find nowadays :)
    >
    > Well, judging by the OP's response you appear to be in possession of a
    > pair :)


    Great-grandmother's legacy, and not for sale!

    --
    Gabriel Genellina
     
    Gabriel Genellina, Aug 22, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Neil Sahar
    Replies:
    1
    Views:
    1,197
    dagreat
    Jan 10, 2005
  2. A. Name
    Replies:
    2
    Views:
    285
    Gianni Mariani
    Sep 15, 2003
  3. slyraymond
    Replies:
    5
    Views:
    279
    Mark Lutz
    Apr 26, 2004
  4. marek

    unicode regex example: trouble

    marek, May 21, 2004, in forum: Python
    Replies:
    1
    Views:
    369
    Peter Otten
    May 21, 2004
  5. Sam Roberts
    Replies:
    15
    Views:
    303
    Sam Roberts
    Feb 7, 2005
Loading...

Share This Page