Programming Forums
User Name Password Register
 

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

Reply
 
Thread Tools Display Modes
Old May 26th, 2006, 12:07 AM   #1
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 931
Rep Power: 4 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
GET/POST vars in Python

I just started learning Python, and I'm trying to figure out how to access GET/POST form variables. Anyone know? Thanks.
titaniumdecoy is offline   Reply With Quote
Old May 26th, 2006, 12:13 AM   #2
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 2,086
Rep Power: 6 Sane will become famous soon enough
Send a message via MSN to Sane
With... raw sockets? CherryPy? CGI?

...
Sane is offline   Reply With Quote
Old May 26th, 2006, 12:15 AM   #3
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 931
Rep Power: 4 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
That sounds sorta complicated. Isn't there an easy way to do it? In PHP you can use $_GET['var'] or $_POST['var']...

EDIT: I believe this article covers what I was looking for.

Last edited by titaniumdecoy; May 26th, 2006 at 12:36 AM.
titaniumdecoy is offline   Reply With Quote
Old May 26th, 2006, 12:39 AM   #4
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 2,086
Rep Power: 6 Sane will become famous soon enough
Send a message via MSN to Sane
No... I was asking you what the medium was for attaining the arguments? Are you trying to do it
Quote:
Originally Posted by Sane
With... raw sockets? CherryPy? CGI?
I take it from that tutorial that you were using CGI. Just stick with a tutorial then, not much more to say. Good luck.
Sane is offline   Reply With Quote
Old May 26th, 2006, 1:26 AM   #5
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 931
Rep Power: 4 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
I'm talking about getting information submitted to a script by an HTML form. If there's an easier/better way to do it than by using the CGI module, I'd be glad to hear about it.
titaniumdecoy is offline   Reply With Quote
Old May 26th, 2006, 1:30 AM   #6
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 2,086
Rep Power: 6 Sane will become famous soon enough
Send a message via MSN to Sane
I know that's what you're talking about, but it would have helped if you said what you're listening to the HTTP packets with. CherryPy, for example, makes this very easy for you. The POST/GET arguments come in directly as arguments to the functions you map to pages. http://cherrypy.org can teach you all about CherryPy.

Raw Sockets you would have to parse yourself. Not sure about CGI. Not aware of any other methods, other then the HTTP module that interfaces to the socket library.
Sane is offline   Reply With Quote
Old May 26th, 2006, 1:33 AM   #7
DaveQB
Newbie
 
DaveQB's Avatar
 
Join Date: Apr 2006
Location: Sydney
Posts: 14
Rep Power: 0 DaveQB is on a distinguished road
Send a message via ICQ to DaveQB Send a message via Skype™ to DaveQB
CGI module is the way to go. Its not too hard, very similiar to PHP besides the import statement.
DaveQB is offline   Reply With Quote
Old May 26th, 2006, 4:04 AM   #8
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
Originally Posted by DaveQB
CGI module is the way to go. Its not too hard, very similiar to PHP besides the import statement.
CGI is the way to go only if you have no alternative. If your host restricts you to Python CGI, then that's what you have to use. If you have no such restriction, I can think of absolutely no advantage of using CGI.
Arevos is offline   Reply With Quote
Old May 26th, 2006, 11:32 AM   #9
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 931
Rep Power: 4 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
Thanks DaWei.

Quote:
Originally Posted by Arevos
CGI is the way to go only if you have no alternative. If your host restricts you to Python CGI, then that's what you have to use. If you have no such restriction, I can think of absolutely no advantage of using CGI.
Why is CGI so bad? Would you suggest using CherryPy like Sane?
titaniumdecoy is offline   Reply With Quote
Old May 26th, 2006, 1:41 PM   #10
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
Originally Posted by titaniumdecoy
Why is CGI so bad? Would you suggest using CherryPy like Sane?
CGI is lowest common denominator stuff. It's both the slowest, and most basic, way in which to use Python to create a web app.

I'd be tempted by Django or Turbogears for a project of reasonable size. Smaller projects I'd use PHP for, I think. Perhaps mod_python if it were available.

But if you wish to use Python, and your host doesn't have mod_python or FastCGI or whatever, you're pretty much stuck with basic CGI.
Arevos 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 4:04 AM.

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