Dotan Cohen wrote: >>> 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?
Using a framework? In Pylons/TG2, my code looks like this: def some_form_action(self, name, email, password): .... so HTTP-variables get parsed, validated, converted, and *then* passed to my actual code. >> 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). Oh my god. If two newlines are all you think that there is to properly writing HTTP-headers, no wonder *you* wonder what to use a webframework for. http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.3 http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6.2 That's just an *overwiew* of what different kinds of headers there are, all of which might require specific rules to parse or generate. > >> Do you respect character >> encodings? > > Yes! UTF-8 from database to scripting language to HTTP request. And if the browser sends them in different encoding? Frameworks make you deals with unicode only. Decoding/Encoding, setting the necessary >> 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? Frameworks do check for HTTP-headers that contain the encoding, and thus convert incoming data to unicode. > > >> Is your generated HTML valid? > > Naturally, even though this is not a Python issue. "Naturally" with print-statements? I use genshi templating, which is XML-based, so I can't even write invalid HTML for a great deal of cases. > > >> 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? The thing is that using a framework, I just pass a datetime-object. Others have done it right for me translating that to the needed format. > > >> 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. Again, you don't seem to really know much about webapps. Content-negotiation isn't about languages, it's about content-types. Such as serving HTML or JSON from the same URL. But let me guess, you hate applications that do that? > > >> 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! I don't have the *slightest* doubt about that. In fact, I'm pretty sure you can make pretty bad webapplications in pretty much everything you touch. Good luck with that. Diez -- http://mail.python.org/mailman/listinfo/python-list