Web development with Python 3.1

Dotan Cohen dotancohen at gmail.com
Wed Oct 28 06:12:00 EDT 2009


>> I should probably expand on this:
>>
>> How can I get an array with all the GET variables in Python?
>> How can I get an array with all the POST variables in Python?
>> How can I get an array with all the COOKIE variables in Python?
>> How can I get the request URI path (everything after
>> http://[www.?]example.com/)?
>>
>> That's all I want: no templates and nothing between me and the HTML.
>> The HTTP headers I can output to stdout myself as well.
>
> Again: if you insist on doing everything yourself - then of course any
> library or framework isn't for you.
>

I insist on handling the HTML myself. As for converting the request
variables into Python variables, if a class/framework makes that
easier then I would gladly use it. My question was serious. How can I
do those things?


> But then do you deal with headers correctly?

Yes, so far as I know. This is actually simpler than the HTML, just be
careful not to output two newline characters in sequence (thereby
ending the header).

> Do you respect character
> encodings?

Yes! UTF-8 from database to scripting language to HTTP request.


> Form-encodings?

Yes, UTF-8 the in the other direction. However, as form data can be
spoofed, I would like a function that checks it. Does Python have such
a function? What class does?


> Is your generated HTML valid?

Naturally, even though this is not a Python issue.


> Are
> timestamp-formats generated according to RFCs for your cookies?

Yes, this is not a problem. Is there some gothcha that I am unaware of?


> Do you parse
> content negotiation headers?
>

No. I hate sites that do that. If the page is available in another
language, their is a link in the corner.


> I think you underestimate the task it is to make a webapplication good.

Probably, but that would not depend on the scripting language. I make
bad webapplications in PHP too!


> And
> even if not, what you will do is ... code your own webframework.

That is why I am looking for a class that handles the backend stuff,
but lets _me_ handle the HTML.


> Because
> there is a lot of boilerplate otherwis. If that's a learning-experience your
> after, fine.
>
> Besides, yes, you can get all these things nonetheless. You just don't need
> them most of the time.
>
> And at least pylons/TG2 lets you return whatever you want instead, as a
> string. Not via "print" though - which is simply only for CGI, and no other
> means (e.g. mod_wsgi) of python-web-programming.
>

I am trying to follow you here. What is "return whatever you want"?
Return HTML to stdout to be sent to the browser?


-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il



More information about the Python-list mailing list