[Tutor] Newbie College Student

2007-08-05 Thread TheSarge

Hi All,

Been tasked with an assignment that is kicking my butt. We have been asked
to write a py utilizing cgi to ask for simplistic web form guestbook
information (name and email). I think I am lost on whether or not my actual
py script needs to link to a cgi script or if I can do it all in a py
script. It needs to log entries to a text file and everytime I think I have
it working I go to my text file and it remains empty. I don't know if I can
post my script code in here so if I can not then my apologies forthcoming.
Any help or advice is most appreciated.

py script:

#!c:\python25\python.exe
import cgi, cgitb, os

temp = """



First Name: 
Last Name: 
Email:  






"""
path = 'c:\\file'
# Create instance of FieldStorage 
form = cgi.FieldStorage() 

# Get data from field 'name' 
fname = form.getvalue('fname') 

# Get data from field 'address' 
lname = form.getvalue('lname') 

# Get data from field 'email' 
email = form.getvalue('email')

if not os.path.isdir(path):
os.mkdir(path)
e=open(path + '\\' + 'logbook.txt','a')
e.write("%s#%s#%s\n" % (fname,lname,email))
e.close()
print 'Done'


What am I doing wrong? Been working on this two weekends in a row and the
assignment is already late.

Thanks,

TheSarge
-- 
View this message in context: 
http://www.nabble.com/Newbie-College-Student-tf4220394.html#a12006185
Sent from the Python - tutor mailing list archive at Nabble.com.

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


[Tutor] Shelve problem

2007-08-08 Thread TheSarge

I have five data files, that are used to build a database.

1.txt
2.txt
3.txt
4.text
5.txt

I want to build a database using a persistent dictionary (shelve).

The specifications are that the key for each dictionary keyword pair, is the
lefthand side 
value of the # sign, and the corresponding value for the data is the phrase
on the 
righthand side.

Can someone help me manipulate this please? I can't not get a grasp on
shelves and on what I need to do.

Thanks,

TheSarge

-- 
View this message in context: 
http://www.nabble.com/Shelve-problem-tf4239852.html#a12064251
Sent from the Python - tutor mailing list archive at Nabble.com.

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