Web development with Python 3.1
dotancohen at gmail.com
Wed Oct 28 14:29:42 CET 2009
>> I have no idea what reverse url generation is.
> It's a mean to avoid hard-coding urls in your application code - the url is
> fully generated by the 'url mapping' system.
I don't need that, see below.
>> I assume that the user
>> will call http://example.com/path/to/script.py?var1=hello&var2=world
>> script.py would live in /home/user/site-name/public_html/path/to/
> Now try to use apache url rewrites to use "nice urls" (like,
> "/<section-name>/<sub-section-name>/<article-name>" instead of
> "path/to/script-serving-articles.wtf?id=42"). Good luck.
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. See the pages
on http://dotancohen.com for examples.
>> I would prefer to output everything from <html> to </html> with print
>> statements. I don't want some framework wrapping my output in tags, I
>> want the tags to be part of the output.
> You're confusing the framework and the templating system. The framework by
> itself won't wrap your "output" in anything, nor even forces you to "output"
This is what I was hoping to hear. I don't remember the details, but I
had a hard time outputting the HTML myself in Django. I will play with
it again soon if I get the chance.
> Also FWIW, it's HTTP, so we don't have "outputs", we have HTTP
Clearly. I was referring to stdout being send to the browser as the
http response. I think I mentioned that, but I apologize for being
>> Yes, why not?
> Let's say I want to reuse your app with a different presentation. Do I have
> to fork the whole application and send my HTML coder dig into your
> applicative code just to rewrite the HTML parts ?
No, just replace two files. In that manner it is templating. Again, an
example from the current PHP code:
// content here
>> Like I said before, I don't want to have to maintain the functions
>> that turn the HTTP environment into Python variables,
> "HTTP environment" ???
> Oh, you mean HTTP requests etc... Well, the cgi module already provides some
> basic support here.
Does it? I will look into that. I assume that basic support means
making the cookie, GET and POST variables easily accessible. I google,
but cannot find any exapmles of this online.
>> or the code that
>> manages database connections. Functions that escape data to be sent to
>> MySQL (to prevent sql injection) would be nice.
> Any DB-API compliant module already provide this - granted you use it
I know. This is will use correctly, I promise!
>> Other than that, it's
>> all on me.
> Your choice...
Hey! Since when am I not under attack? :)
More information about the Python-list