Re: is there an Python equivalent for the PHP super globals like $_POST, $_COOKIE ?
On 12/11/10 01:25, Roy Smith wrote: In articleibhi4h$ev...@speranza.aioe.org, r0gaioe@technicalbloke.com wrote: On 11/11/10 14:22, Stef Mientki wrote: I can't find how th get to PHP's equivalent of $_Post and $_Cookie ? PHP is mostly a one-trick pony. It's meant to be run as a web scripting language with Apache (or, I suppose, something else) on the front end. As a result, a lot of web-specific things like $_Post and $_Cookie are built into the language. Python is intended to be more general purpose, so things which are built in to other languages usually can be found in library modules. In this case, you probably want to look at the SimpleHTTPServer module. Actually when they say Simple they really mean it. The the SimpleHTTPServer module doesn't parse form data at all. It's pretty easy to get that using the urlparse module though... def do_GET(self): getvars = urlparse.parse_qs( self.path ) field1 = getvars[ username ][0] field2 = getvars[ password ][0] if authenticate( field1, filed2 ): self.send_response(200) self.send_header(Content-type, text/html) self.end_headers() self.wfile.write( welcome ) else: self.send_response(404) self.end_headers() return This may be lower level than you want really and does involve permanently running a daemon on your server as opposed to the PHP way of doing things (having Apache interpret PHP on a page by page basis). My latest gig, however, has had me doing PHP for the past 3 months or so. That's terrible, you have my fullest sympathy in these difficult times. Roger -- http://mail.python.org/mailman/listinfo/python-list
Re: is there an Python equivalent for the PHP super globals like $_POST, $_COOKIE ?
In article ibr0tl$ai...@speranza.aioe.org, r0g aioe@technicalbloke.com wrote: My latest gig, however, has had me doing PHP for the past 3 months or so. That's terrible, you have my fullest sympathy in these difficult times. Actually, in a sick sort of way, it's fun. We regularly have PHP bashing sessions in the office when somebody discovers yet another depraved piece of language mis-design and we all get a good laugh out of it. No all languages afford you the opportunity for this kind of entertainment. It's also quite educational. You can learn a lot about language design by observing the mistakes that can be made. -- http://mail.python.org/mailman/listinfo/python-list
Re: is there an Python equivalent for the PHP super globals like $_POST, $_COOKIE ?
On 2010-11-12, Martin Gregorie mar...@address-in-sig.invalid wrote: On Thu, 11 Nov 2010 13:01:01 -0500, Steve Holden wrote: Moving from one language to anther is not just a matter of transliterating the code. Of you try that you will end up with a messy code base that looks like PHP written in Python. The determined Real Programmer can write Fortran programs in any language. They probably won't run quite as as fast, though. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list
is there an Python equivalent for the PHP super globals like $_POST, $_COOKIE ?
hello, finally got Python running at my server. Now I would like to replace the PHP server scripts with Python ( for easier maintenance). But I can't find how th get to PHP's equivalent of $_Post and $_Cookie ? Google finds lots of links, but I can't find the answer. thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: is there an Python equivalent for the PHP super globals like $_POST, $_COOKIE ?
On 11/11/2010 9:22 AM, Stef Mientki wrote: hello, finally got Python running at my server. Now I would like to replace the PHP server scripts with Python ( for easier maintenance). But I can't find how th get to PHP's equivalent of $_Post and $_Cookie ? Google finds lots of links, but I can't find the answer. thanks, Stef Mientki Stef: Moving from one language to anther is not just a matter of transliterating the code. Of you try that you will end up with a messy code base that looks like PHP written in Python. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: is there an Python equivalent for the PHP super globals like $_POST, $_COOKIE ?
On 11-11-2010 19:01, Steve Holden wrote: On 11/11/2010 9:22 AM, Stef Mientki wrote: hello, finally got Python running at my server. Now I would like to replace the PHP server scripts with Python ( for easier maintenance). But I can't find how th get to PHP's equivalent of $_Post and $_Cookie ? Google finds lots of links, but I can't find the answer. thanks, Stef Mientki Stef: Moving from one language to anther is not just a matter of transliterating the code. Of you try that you will end up with a messy code base that looks like PHP written in Python. Steve I agree with you, but replacing a number of 3 to 10 lines of code scripts won't create a mess ;-) cheers, Stef regards Steve -- http://mail.python.org/mailman/listinfo/python-list
Re: is there an Python equivalent for the PHP super globals like $_POST, $_COOKIE ?
From: Stef Mientki stef.mien...@gmail.com To: python-list@python.org Sent: Thu, November 11, 2010 10:20:03 AM Subject: Re: is there an Python equivalent for the PHP super globals like $_POST, $_COOKIE ? On 11-11-2010 19:01, Steve Holden wrote: On 11/11/2010 9:22 AM, Stef Mientki wrote: hello, finally got Python running at my server. Now I would like to replace the PHP server scripts with Python ( for easier maintenance). But I can't find how th get to PHP's equivalent of $_Post and $_Cookie ? Google finds lots of links, but I can't find the answer. thanks, Stef Mientki Stef: Moving from one language to anther is not just a matter of transliterating the code. Of you try that you will end up with a messy code base that looks like PHP written in Python. - Steve I agree with you, - but replacing a number of 3 to 10 lines of code scripts won't create a mess ;-) So, assuming you want the 'straight ahead' (i.e. no framework, like Django) your looking at vanilla CGI programming. form = cgi.FieldStorage() # parse query string, handles decoding and GET and POST print pname:, form[name].value http://docs.python.org/library/cgi.html Enjoy! :) David-- http://mail.python.org/mailman/listinfo/python-list
Re: is there an Python equivalent for the PHP super globals like $_POST, $_COOKIE ?
On 11-11-2010 19:36, david wright wrote: *From:* Stef Mientki stef.mien...@gmail.com *To:* python-list@python.org *Sent:* Thu, November 11, 2010 10:20:03 AM *Subject:* Re: is there an Python equivalent for the PHP super globals like $_POST, $_COOKIE ? On 11-11-2010 19:01, Steve Holden wrote: On 11/11/2010 9:22 AM, Stef Mientki wrote: hello, finally got Python running at my server. Now I would like to replace the PHP server scripts with Python ( for easier maintenance). But I can't find how th get to PHP's equivalent of $_Post and $_Cookie ? Google finds lots of links, but I can't find the answer. thanks, Stef Mientki Stef: Moving from one language to anther is not just a matter of transliterating the code. Of you try that you will end up with a messy code base that looks like PHP written in Python. - Steve I agree with you, - but replacing a number of 3 to 10 lines of code scripts won't create a mess ;-) So, assuming you want the 'straight ahead' (i.e. no framework, like Django) your looking at vanilla CGI programming. form = cgi.FieldStorage() # parse query string, handles decoding and GET and POST print pname:, form[name].value http://docs.python.org/library/cgi.html thanks David, looks that was what I was looking for, I'll investigate all the properties of Fieldstorage. thanks, Stef Enjoy! :) David -- http://mail.python.org/mailman/listinfo/python-list
Re: is there an Python equivalent for the PHP super globals like $_POST, $_COOKIE ?
On 11/11/10 14:22, Stef Mientki wrote: hello, finally got Python running at my server. Now I would like to replace the PHP server scripts with Python ( for easier maintenance). But I can't find how th get to PHP's equivalent of $_Post and $_Cookie ? Google finds lots of links, but I can't find the answer. thanks, Stef Mientki PHP only tends to be run one way, the mod_php Apache module. There's several ways run python in conjunction with a webserver like apache: mod_wsgi, mod_python, CGI and FastCGI. I've never really looked into this way of doing things but I guess the details are going to vary depending on which one you use. It's also not uncommon for python to actually BE the webserver too, there's lots of webserver modules for python, cherrypy is fairly simple and well regarded. Often you can proxy these through Apache to get the benefits of both although again, that's not an approach I've used so I can't really advise you further. Roger. -- http://mail.python.org/mailman/listinfo/python-list
Re: is there an Python equivalent for the PHP super globals like $_POST, $_COOKIE ?
On 2010-11-11 11:20, Stef Mientki wrote: On 11-11-2010 19:01, Steve Holden wrote: On 11/11/2010 9:22 AM, Stef Mientki wrote: hello, finally got Python running at my server. Now I would like to replace the PHP server scripts with Python ( for easier maintenance). But I can't find how th get to PHP's equivalent of $_Post and $_Cookie ? Google finds lots of links, but I can't find the answer. thanks, Stef Mientki Stef: Moving from one language to anther is not just a matter of transliterating the code. Of you try that you will end up with a messy code base that looks like PHP written in Python. Steve I agree with you, but replacing a number of 3 to 10 lines of code scripts won't create a mess ;-) cheers, Stef regards Steve If there is no automated process to do the translation, then it should be avoided. It is an opportunity for chaos to ensue. -- http://mail.python.org/mailman/listinfo/python-list
Re: is there an Python equivalent for the PHP super globals like $_POST, $_COOKIE ?
On 11/11/10 18:01, Steve Holden wrote: On 11/11/2010 9:22 AM, Stef Mientki wrote: hello, finally got Python running at my server. Now I would like to replace the PHP server scripts with Python ( for easier maintenance). But I can't find how th get to PHP's equivalent of $_Post and $_Cookie ? Google finds lots of links, but I can't find the answer. thanks, Stef Mientki Stef: Moving from one language to anther is not just a matter of transliterating the code. Of you try that you will end up with a messy code base that looks like PHP written in Python. regards Steve Come on Steve, I thought your role is to encourage / cheerlead here ;D While you're absolutely right when it comes to complex apps and sites I get the impression he's only talking about your common or garden short admin scripts. I might be wrong though. Roger -- http://mail.python.org/mailman/listinfo/python-list
Re: is there an Python equivalent for the PHP super globals like $_POST, $_COOKIE ?
On 11/11/2010 3:23 PM, r0g wrote: On 11/11/10 18:01, Steve Holden wrote: On 11/11/2010 9:22 AM, Stef Mientki wrote: hello, finally got Python running at my server. Now I would like to replace the PHP server scripts with Python ( for easier maintenance). But I can't find how th get to PHP's equivalent of $_Post and $_Cookie ? Google finds lots of links, but I can't find the answer. thanks, Stef Mientki Stef: Moving from one language to anther is not just a matter of transliterating the code. Of you try that you will end up with a messy code base that looks like PHP written in Python. regards Steve Come on Steve, I thought your role is to encourage / cheerlead here ;D While you're absolutely right when it comes to complex apps and sites I get the impression he's only talking about your common or garden short admin scripts. I might be wrong though. Roger I'm quite happy to encourage, but I do find it necessary to interject a warning from time to time. I was pretty sure someone with PHP knowledge would come to the rescue. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 PyCon 2011 Atlanta March 9-17 http://us.pycon.org/ See Python Video! http://python.mirocommunity.org/ Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: is there an Python equivalent for the PHP super globals like $_POST, $_COOKIE ?
In article ibhi4h$ev...@speranza.aioe.org, r0g aioe@technicalbloke.com wrote: On 11/11/10 14:22, Stef Mientki wrote: I can't find how th get to PHP's equivalent of $_Post and $_Cookie ? PHP is mostly a one-trick pony. It's meant to be run as a web scripting language with Apache (or, I suppose, something else) on the front end. As a result, a lot of web-specific things like $_Post and $_Cookie are built into the language. Python is intended to be more general purpose, so things which are built in to other languages usually can be found in library modules. In this case, you probably want to look at the SimpleHTTPServer module. You may also want to look at any of several web application frameworks such as Django, Pylons, etc. I'm guessing these are overkill for the sorts of things you want to do, but they're worth at least browsing to get some idea of what's out there. For what it's worth, I've pretty much avoided PHP for all these years. My latest gig, however, has had me doing PHP for the past 3 months or so. The more I learn about PHP, the more I want to go running in the other direction. -- http://mail.python.org/mailman/listinfo/python-list
Re: is there an Python equivalent for the PHP super globals like $_POST, $_COOKIE ?
On Thu, 11 Nov 2010 13:01:01 -0500, Steve Holden wrote: Moving from one language to anther is not just a matter of transliterating the code. Of you try that you will end up with a messy code base that looks like PHP written in Python. The determined Real Programmer can write Fortran programs in any language. - from Real Programmers don't use Pascal. -- martin@ | Martin Gregorie gregorie. | Essex, UK org | -- http://mail.python.org/mailman/listinfo/python-list