Web development with Python 3.1

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Wed Oct 28 07:10:35 EDT 2009


Dotan Cohen a écrit :
> 2009/10/28 Bruno Desthuilliers <bruno.42.desthuilliers at websiteburo.invalid>:
>> Dotan Cohen a écrit :
>>>> declarative mapping of urls to code
>>> Apache does this, unless I am misunderstanding you.
>> Using url rewriting ? Yes, fine. Then tell me how you implement "reverse"
>> url generation (like Django or Routes do).
> 
> 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 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.

> 
>>>> of code to templates
>>> Those who code in HTML don't need this.
>> ???
>>
> 
> 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" HTML. Also FWIW, it's HTTP, so we don't have "outputs", we have 
HTTP responses.

> 
>>> In any case it's not hard to
>>> call a function in a class that writes the HTML before the content,
>>> then write the content, then call another function that writes the
>>> HTML after the content.
>> Hmmm, yummy !  And SO maintainable...
>>
> 
> 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 ?

> 
>>> This is how my sites are run, though in PHP
>>> instead of Python. No prepackaged templates.
>> PHP *is* a template language.

(snip)

>>> I would really like to know what else. So far, I am not convinced that
>>> a framework offers anything that is not already easily accomplished in
>>> Python.
>> Given that we're talking about Python frameworks, it seems obvious that what
>> they do can be accomplished in Python. Now the question is how much you like
>> to write the same boring and error-prone boilerplate code project after
>> project...
>>
> 
> 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.

> 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 
correctly.

> Other than that, it's
> all on me.

Your choice...



More information about the Python-list mailing list