Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 7th, 2005, 4:58 PM   #1
Eragon229
Newbie
 
Join Date: Jul 2005
Posts: 14
Rep Power: 0 Eragon229 is an unknown quantity at this point
Error Trapping and putting a program on a web site not as a file download.

Ok. I need a simple error trapping code please. And how do you place a program on a web page without it being a downloadable file? After I get my answers I'm out of your hair until I finish the tutorial. Which didn't have anything about error trapping. Thanks
__________________
Scientists prove this. Scientists prove that. They discover this, discover that. Though it seems there will be nothing left the discover, wrongo. Look beyond. I see no boundaries. The only boundaries, are your determination, your imagination, your intuition, and your knowledge. But it all started with a dream.
Eragon229 is offline   Reply With Quote
Old Aug 8th, 2005, 12:19 AM   #2
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,868
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Error trapping code? You may have to be more specific. But you catch errors with try and except.

#invalid_variable = 42
try: print invalid_variable
except: print "Variable Doesn't Yet Exist"
print 'Done'

And for an ftp at least, you can go ...right click > properties > permission > uncheck read access... if you are the owner.

But that means no one can view or download it except you.
Sane is offline   Reply With Quote
Old Aug 8th, 2005, 1:30 PM   #3
Cerulean
Professional Programmer
 
Cerulean's Avatar
 
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4 Cerulean is on a distinguished road
Yes, try and except as shown in Sane's example, but make sure you tell the interpreter what kind of error you're excepting - faster to run, and faster to read (when you come back to a piece of code after months you won't be blindly asking yourself what kind of error you're trying to except).
In that example it would be:
try:
    print invalid_variable
except NameError:
    print "Variable doesn't exist yet.."
Quote:
And how do you place a program on a web page without it being a downloadable file?
Eh? You mean so that the script runs on the server and outputs information for your webpage? If so, you'll need a host that supports mod_python or supports CGI and has Python installed on the server.
Cerulean is offline   Reply With Quote
Old Aug 9th, 2005, 2:58 AM   #4
Berto
Programming Guru
 
Join Date: Aug 2004
Posts: 1,022
Rep Power: 6 Berto is on a distinguished road
Send a message via AIM to Berto Send a message via MSN to Berto
although i dont no if python has it, you should have a finally block, which is always run, to close db connections etc, and also a catchall exception otherwise there might be one you can miss.
__________________
"Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute. THAT'S relativity."

- Albert Einstein
Berto is offline   Reply With Quote
Old Aug 9th, 2005, 1:48 PM   #5
Cerulean
Professional Programmer
 
Cerulean's Avatar
 
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4 Cerulean is on a distinguished road
Yep, Python supports finally. As for a catchall exception.. probably not a good idea, as you won't know how precisely to clean up or fix the problem that's arisen.
Cerulean is offline   Reply With Quote
Old Aug 10th, 2005, 2:34 AM   #6
Berto
Programming Guru
 
Join Date: Aug 2004
Posts: 1,022
Rep Power: 6 Berto is on a distinguished road
Send a message via AIM to Berto Send a message via MSN to Berto
Yeah i understand that one, but i normally put one in for the errors i dont no that might occur to close the program effectivly and not have things still stuck in memory, and also log the error, for later purposes of fixing it.
__________________
"Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute. THAT'S relativity."

- Albert Einstein
Berto is offline   Reply With Quote
Old Aug 25th, 2005, 5:57 PM   #7
Eragon229
Newbie
 
Join Date: Jul 2005
Posts: 14
Rep Power: 0 Eragon229 is an unknown quantity at this point
Thanks guys.
Eragon229 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:23 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC