Web development with Python 3.1

Dotan Cohen dotancohen at gmail.com
Wed Oct 28 15:53:36 EDT 2009


>> Actually, currently in the example url
>> http://example.com/path/to/script.py?var1=hello&var2=world the script
>> is /home/user/site-name/public_html/path/ (with no filename extension)
>> and the script.py is actually page.html which is an arbitrary,
>> descriptive string and not part of the script filename.
>
> Better than the first example wrt/ SEO, but this still ties your "url space"
> to implementation AFAICT.
>

Yes, but for the purposes of my needs this is fine and preferable. SEO
was in fact the reason that I started doing this.


>> Clearly. I was referring to stdout being send to the browser as the
>> http response.
>
> s/browser/web server/ - it's the web server that reads your app's stdout and
> send it (as is or not FWIW) back to the client.

As is, in my case. Actually, what use case is there for having Apache
reprocess the HTML output of the script?


>  And this "output to stdout"
> thingie is just the ipc scheme used for CGI - there are other possible
> interfaces between the application code and the web server.
>

Other possible interfaces between the application code and the web
server? Maybe you are referring to the interface with the database
server? Enlighten me, please! I am not a programmer by trade, only by
hobby.


>> I think I mentioned that, but I apologize for being
>> unclear.
>
> It's not that it was unclear, but that it's innaccurate. "outputting to
> stdout" is an implementation detail, and should not be exposed at the
> applicative code level. Dealing with appropriate abstraction - here, an
> HttpResponse object - is far better (well, IMHO of course... - standard
> disclaimers, YMMV etc).
>

I see. I believe that is called Dotan's Razor: a slight inaccuracy
saves a lengthy explanation.


> Sorry, but all I can "replace" here are the header and footer - if I want to
> generate a different markup for the "content here" part, I have to modify
> your applicative code. I've written web apps that way myself (some 7 years
> ago), and still have to maintain some web apps written that way, you know...
>

Quite so, I though that is what you wanted. Yes, the HTML is
hard-coded into the script. I am learning to abstract and even use
object-oriented approaches, though.


>> Does it? I will look into that. I assume that basic support means
>> making the cookie, GET and POST variables easily accessible.
>
> GET and POST at least - I don't exactly remember how it works for cookies.
>

That much I should be able to google when I get to it.


>> I google,
>> but cannot find any exapmles of this online.
>
> Well, no one in it's own mind would still use CGI (except perhaps for very
> trivial stuff) when you have way better solutions.
>

What I am doing _is_ trivial. However, I thank you for explaining my
options and I will take a second look at them.


>> Hey! Since when am I not under attack? :)
>
> Mmm... yes, I tend to be a bit offensive sometimes - please don't take it
> personnaly and forgive me for my lack of social skills. What I express are
> of course _my_ opinions (most of them based on experience but that's not the
> point), and I've never killed anyone for having a different POV - even if
> I'm pretty sure they are wrong !-)
>

Be offensive! I take no offence, I understand that your goal is to
help me. I am a hard learner: I recognize that you are teaching me the
better way, but I need convincing as to why it is better. "Bruno said
so" is good, but "saves you coding time down the line" is a lot more
convincing!


-- 
Dotan Cohen

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



More information about the Python-list mailing list