The Artima Developer Community
Sponsored Link

Weblogs Forum
Please Teach me Web Frameworks for Python!

104 replies on 7 pages. Most recent reply: Sep 28, 2008 10:31 PM by brianna americana

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 104 replies on 7 pages [ « | 1 ... 2 3 4 5 6 7 | » ]
Doug Winter

Posts: 3
Nickname: winjer
Registered: Oct, 2003

Re: Please Teach me Web Frameworks for Python! Posted: Jan 28, 2006 1:11 AM
Reply to this message Reply
Advertisement
I've had a look at a number of these frameworks in detail, and here is my take.

First, if I may say, your comment about XML is frankly weird. Since you are producing XML output, you are almost certainly going to have to write some XML somewhere. Bizarrely the only system you have looked at in which it is sensible to generate HTML without any XML input at all is Nevow (which provides Stan) and this is the very system you criticised.

1. Django

Too much magic. They are set on magic removal, but I still think their API generation stuff is a nightmare-in-waiting Using Regexs to specify the UI is evil and unpredictable.

2. Nevow

The more complex your application, the better suited Nevow is to it. It's fast and it's definitely coder-driven. It's more lispish than pythonic I guess, and deferreds will make you much keener on PEP343 :)

Nevow probably isn't ready for widespread adoption yet, as I think glyph would agree.

3. Zope 2

Nightmarish, avoid if possible. That said, it's the only one of these web frameworks to gain real traction, but it's really showing it's age now.

4. Zope 3

Looks very good so far, but is tarnished by the Zope name. Definitely worth considering.

5. TurboGears

Probably the most pythonic of the options. It looks like a rough assemblage of random components but the fact they play so nicely together is a testament to their quality. You should look at this one too.

Stefane Fermigier

Posts: 2
Nickname: fermigier
Registered: Oct, 2003

Re: Please Teach me Web Frameworks for Python! Posted: Jan 28, 2006 4:07 AM
Reply to this message Reply
Check my blog entry on the Python web (mega)frameworks and their common components (http://blogs.nuxeo.com/sections/blogs/fermigier/2006_01_22_updated-megaframeworks). Hope that helps clarify some points.

Anthony Tarlano

Posts: 9
Nickname: tarlano
Registered: Jun, 2003

Re: Please Teach me Web Frameworks for Python! Posted: Jan 28, 2006 4:12 AM
Reply to this message Reply
Guido,

IMHO no one can tell you which Web Application Technology will be best suited to your requirements and constraints, since only you know your personal taste when you open up your editor and peer through someone else's codified constraints and requirements.

I have used many of the candidates mentioned so far, but not all, so I will let other responders answer your question on "where to start?".

I would like to just echo something that you said that I do agree with: "I like [Quixote's] approach to templating: instead of inventing a brand new templating language, it makes one tiny modification to Python".

I do ask one thing from you, please after you have finished your "starter project" post details both on where you started as well as where you ended.

Jim Carroll

Posts: 7
Nickname: mrmaple
Registered: Jan, 2006

Turbogears gets my vote. Posted: Jan 28, 2006 8:51 AM
Reply to this message Reply
Hi Guido, I have done php, java (mostly .jsp pages), and zope development. Today I would use Turbogears, because it improves all aspects of my current favorite Zope2 technique.

In Zope, I use a page to show the contents of the database, links to pages that allow editing that pull from python scripts based on some database ID using ZSQL against MySQL, then the editing page has another script as an Action that validates, and changes the dates to MySQL format, then invokes more ZSQL & redirects to the next page. The problem is that any one edit & save operation is spread out against two ZPT templates, two Scripts, and two ZSQL objects... if something goes wrong the error messages don't point to the source of the problem, it takes quite a bit of thinking to figure out where the problem really is. I end up having to help my coworkers with this more often than I should.

Using just the CherryPy part of Turbogears and the Kid templates is attractive because all the things that (in Zope) are spread out across multiple python scripts and ZSQL objects is in one .py file accessing MySQL directly, and the error messages really do point to the problem. The Kid templates polish some of the rough edges of the ZPT templates... I find I don't need as many tal:define statenmenst to set up things to work nicely.

The only reason that I'm not using Turbogears at the moment is that I had trouble deploying it on my Mac Mini. I couldn't get mod_python to compile just right. I want to use mod_python because apache will re-launch my application on the first request after apache starts without having to have a different mechanism to start my Turbogears app.

One reason I don't think Turbogears is the ultimate web app framework is that every request causes Python functions to get interpreted. In the wxPython + C++ work I do my goal is that anything time critical is handled 100% by C++, and the Python is used to wire together the C++ objects at startup time. Someday the high performance possible with python/C++ hybrid programming will create the ultimate web server. The trick is getting the database access and string manipulation to be specified in Python at start-up, but then only touch C++ code during a request.

I'd like to hear what GUI tools you use for Python development at Google. The idea of Google putting resources into wxPython & wxWidgets in an open way (maybe even creating development tools to blow C# out of the water) is something I'd love to encourage.

Thanks for Python,
-Jim

Garito .

Posts: 1
Nickname: garito
Registered: Jan, 2006

Re: Please Teach me Web Frameworks for Python! Posted: Jan 28, 2006 9:06 AM
Reply to this message Reply
Hi,

I'm working on Yanged a Zope product that acts like a framework to create reusable web software

On Yanged every piece of code is a "Funcionality" a is fully reusable

I use MVC some years ago and I think there are better approaches and is a little old pattern (in my opinion)

On Yanged we have run path's (run path's, functionality and formulators) to do the work

The language editor is Freemind. You could edit your application behavior with freemind

For example, this is the code for Validar (validate) and is used to validate *ANY* formulator:

## Comando Yanged "Validar"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=args
##title=
##
from Products.Formulator.Form import FormValidationError

if 'Formulario' in args: Formulario = args['Formulario']
elif 'Elemento' in args: Formulario = context.Dame({'tipo': 'Formulario Yanged', 'nombre': args['Elemento'].tipo(args)})
else: Formulario = context.Dame({'tipo': 'Formulario Yanged', 'nombre': args['Path'][0]})

errores = dict()
try:
args['ValoresFormulario'] = Formulario.validate_all_to_request(context.REQUEST)
except FormValidationError, e:
for error in e.errors:
errores[error.field.get_value('title')] = error.error_text

if len(errores): args['Errores'] = errores

if not len(context.REQUEST.form): args['Errores'] = {}

return args

As you can see (if you know any Zope) is a Python Script but a functionality could be anything I could call

Another example this time with a Page Template:

<tal:b tal:define='args python: options["args"][0]'>
<tal:b tal:define='global Elemento python: args["Elemento"]' />
<tal:b tal:define='global Item python: args["Item"]' />
</tal:b>
<div tal:attributes='id Elemento/getId' class="Etiqueta">
<tal:b tal:replace='structure python: Elemento.get_value("title")' />
</div>
<tal:b tal:replace='structure Item' />

These piece of code is called "Etiquetable" and is used to put the label of a formulator field but *ANY* field

All with 1000 lines of unoptimized (refined) code + Funcitionalities

At these moment I'm working on the functionalities (basic with AJAX, actions -groupped functionalities that run's something-...)

What do you thing about it?

Thanks!

Bill de hÓra

Posts: 1137
Nickname: dehora
Registered: May, 2003

Re: Please Teach me Web Frameworks for Python! Posted: Jan 28, 2006 11:19 AM
Reply to this message Reply
Django is best thing out there given the requirements you mentioned. It's stupifyingly productive, the parts are coherent, it has a proper end-to-end story from setup to dpeloyment. I didn't buy your point about magic, in any case, 1.0 will getting rid of most of what is essentially a non-problem.

JOhn Mudd

Posts: 5
Nickname: johnmudd
Registered: Dec, 2005

Re: Please Teach me Web Frameworks for Python! Posted: Jan 28, 2006 2:19 PM
Reply to this message Reply
Almost a year ago I became fascinated with Twisted + Nevow. There's a demo that shows sever side Python driving Ajax apps. Looks simple, cool and it's driven by Python, on the *server* side. I waited, hoping for it to solidify.

Anyway, my wish is that you give this combo a close look. Having you in the user community might push it along.

Kieran Holland

Posts: 1
Nickname: kmh
Registered: Jan, 2006

Django's templating language is a feature Posted: Jan 28, 2006 3:06 PM
Reply to this message Reply
Good to see your interest in a problem that RoR has demonstrated is now crucial to language adoption.

I have been using Django for some time, working together with a designer, and overall I am very satisfied. The core developers are 100% committed, the documentation is outstanding, and the community helpful.

Here are a few reasons why Django's templating is a major feature:

- Simple implementation (parsed with a couple of REs)
- Superfast rendering
- Template inheritance (very DRY)
- Well documented
- Easily accessible to non-programmers
- Extendible by programmers where necessary

In any web project that is not maintained exclusively by programmers I am convinced that anything "more Pythonic/powerful" in the templates is asking for trouble. Django templating is certainly not "rich and powerful" like PHP - it does just enough. If the designer wants complicated logic then Django makes it easy for a programmer to write a custom template tag in regular Python, keeping program logic where it is meant to be.

There has been a bit of API flux since Django went public, with the aim to get the core features just right before a 1.0 release, but backwards incompatible changes have been completely documented. The Django team have guaranteed a stable API after 1.0

Importantly, the core Django developers have a lot of work invested in existing production sites: they know what works and do not make backwards incompatible changes lightly.

LC Rees

Posts: 2
Nickname: lcrees
Registered: Jan, 2006

Re: Please Teach me Web Frameworks for Python! Posted: Jan 28, 2006 3:39 PM
Reply to this message Reply
I'm more of a casual programmer than many of the luminaries posting to this thread. Being a Python fan, however, I follow community developments and I've followed Python web programming discussions in particular for the past few years. Comments from a casual Python programmer with no allegiance to any particular framework couldn't hurt.


I've wanted to pick up web programming but I want to do it in Python. Python "fits in my head" and I don't think about the language while using it. I've fiddled with several Python web frameworks over the years but none of them click the way Python itself does. I want the Python of Python web frameworks but I haven't found it. I want to stop thinking about web framework and start thinking about web applications.


I've run through the Django and TurboGears tutorials and they have some interesting features but they don't feel like they're "it" yet (though that could change). I've looked at some of the projects recommended on this thread but not in any detail. web.py seems more Pythonic in its resemblance to the better PSL libraries but I haven't experimented with it yet.


Though I'm sure Guido's not proposing it here and I doubt it will happen anytime soon, I would be in favor of "one -- and preferably only one -- obvious way to do it" for each of the features Guido lists. There must be best practices that can be codified for each of those features though there may not be a best implementation for all of them in Python yet.
<ul><li>There should be one obvious way to make Python web applications run on a webserver that's easy for hosts to implement and casual programmers to write to.</li><li>There should be one obvious way to mix Python with markup. No templating system should be mandated but if you just wanted to mix <i>just</i> Python and (X)HTML there should be one way to put Python and (X)HTML in a web page, FTP it to a web server, and have it live.


It's ugly and most people here wouldn't use program that way. I personally prefer the in-page templating system be as free of programming logic as possible. But if people are going to do it, they might as well do it in Python instead of an ugly hack like PHP.</li><li>One reason django offers for having yet another templating language is the security advantages of keeping "arbitrary Python code" out of a template. This exposes a missing feature in Python's current library: the lack of a bulletproof "secure execution mechanism". Inclusion of a rexec/Bastion replacement in the PSL solve at least two issues I'm familiar with: The Python procedural language PL/Python being marked as "untrusted" under PostgreSQL and using Python as an in-page templating language.</li></ul>Some varient of all of these common features should ship with the standard library IMHO. But, even if that nevers happen, I welcome Guido's involvement in this area. I understand the advantages of the "let a thousand flowers bloom, a hundred schools of thought contend" approach to encouraging innovation in the Python community. But we've been chasing our tail as a community around the bush on this issue for years when it seems the best practices in the areas Guido outlines are common knowledge now. Other languages provide at least a bad web programming solution (higher than CGI) out of the box while we get nothing despite having a superior language.


Guido's experiences in this area could help lead to a better solution for those who just want something out of the box and are too lazy or ignorant to search for package X and package Y from CheeseShop. There may or may not be much point in serving that demographic but it exists and ought to be using Python instead of something worse. I trust Guido's instincts because, in general, he's shown one quality most language designers (and, by implication, most web framework authors) manifestly lack: good taste.

Foo Bar

Posts: 2
Nickname: throwaway
Registered: Jul, 2003

Re: Please Teach me Web Frameworks for Python! Posted: Jan 28, 2006 5:37 PM
Reply to this message Reply
I've been interested in web.py, too, but it appears to have a relatively restrictive licence, as web frameworks go. :-( Seems as though you have to release your application as open source if you put it on the web. That makes it a nonstarter for me and many others but I bet Guido could get an exemption from the author... I wish he'd been more explicit about that in his introduction of web.py, though. Seems a little sneaky.

(I learned this from the reddit.com comments, somewhat ironically: http://reddit.com/info?id=12l0#c133z. See http://www.affero.org/oagpl.html for the actual licence, especially the summary in the left-hand column.)

Jeff Lewis

Posts: 2
Nickname: jlburly
Registered: Jan, 2006

Re: Please Teach me Web Frameworks for Python! Posted: Jan 28, 2006 7:49 PM
Reply to this message Reply
Sorry if off-topic, but I'm not sure that is what the aogpl license is saying. Reading section 2.d. as a whole, I'm pretty sure it just means that if you use web.py, whether modified, extended/aggregated or in original form, in your app that if a user of your app asks for the src of web.py, you need to provide them with a way to download the src of web.py that your app is using (including the mods and/or derivitives/aggregations if such is the case), not the src for the rest of your app.

I could be wrong of course. You could always ask Aaron S to clarify.

Jeff

> I've been interested in web.py, too, but it appears to
> have a relatively restrictive licence, as web frameworks
> go. :-( Seems as though you have to release your
> application as open source if you put it on the web.
> ...
> See
> http://www.affero.org/oagpl.html for the actual licence,
> especially the summary in the left-hand column.)

mike bayer

Posts: 22
Nickname: zzzeek
Registered: Jan, 2005

Re: Django's templating language is a feature Posted: Jan 28, 2006 8:02 PM
Reply to this message Reply
> Here are a few reasons why Django's templating is a
> major feature
:
>
> - Simple implementation (parsed with a couple of REs)
> - Superfast rendering
> - Template inheritance (very DRY)
> - Well documented
> - Easily accessible to non-programmers
> - Extendible by programmers where necessary
>

Ive been trying to stay out of the Django love-fest going on here, but really, these above features are not very interesting at all. All the major template languages for python now have these features, and in the case of Myghty they are based on a model that is far more widely used than Django's (i.e. that of HTML::Mason). As Guido so aptly mentioned, Django's templating, with its enormous list of functions (all of which are implemented custom, as opposed to drawing upon the Python language itself as Myghty does) is designed for the PHP non-programmer "giant bag of functions" crowd, which is about as un-pythonic as something can get.

Foo Bar

Posts: 2
Nickname: throwaway
Registered: Jul, 2003

Re: Please Teach me Web Frameworks for Python! Posted: Jan 28, 2006 8:27 PM
Reply to this message Reply
I'm not certain on that point, either, but this section seems relevant:

"These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it."

The way I read that, unless your program can run without a copy of web.py, the terms of the licence would apply to its source code as a whole. Adding a file which imports web.py seems like creating a "modified work" to me. But I don't know whether a lawyer would see it that way.

Eugene Lazutkin

Posts: 15
Nickname: elazutkin
Registered: Jan, 2006

Re: Please Teach me Web Frameworks for Python! Posted: Jan 28, 2006 9:38 PM
Reply to this message Reply
> 1. Django
>
> Too much magic. They are set on magic removal, but I
> still think their API generation stuff is a
> nightmare-in-waiting Using Regexs to specify the UI is
> evil and unpredictable.

Is it possible to expand on "nightmare-in-waiting" in light of "set on magic removal"? Who is "Using Regexs to specify the UI"??? I have no idea what you are talking about. So far your take sounds like a pure propaganda without any facts.

Thanks,

Eugene

Paul Boddie

Posts: 26
Nickname: pboddie
Registered: Jan, 2006

Re: Please Teach me Web Frameworks for Python! Posted: Jan 29, 2006 7:57 AM
Reply to this message Reply
[Django]

> Is it possible to expand on "nightmare-in-waiting" in
> light of "set on magic removal"? Who is "Using Regexs to
> specify the UI"??? I have no idea what you are talking
> about. So far your take sounds like a pure propaganda
> without any facts.

From what I've seen of Django and regular expressions, noting that I don't have any interest in the templating system (since I'm an adherent of XML-based templating), the principal application of regexps is in interpreting the path or URL when dispatching to a particular part of an application. I think this is an elegant twist on the way Zope and its predecessors did dispatching: the Zope object publishing mechanism (at least once upon a time) traversed path fragments and called functions and methods providing request parameters as arguments; Django takes the groups from a matching regular expression (applied to the path) and then presents those groups as arguments to the function associated with that particular regexp, meaning that each argument represents some "interesting" part of the URL.

In other words, Django chooses an arguably more interesting use for the arguments/parameters of "published" functions, especially since at least in early Zope-related technologies, the conversion of request parameters wasn't powerful enough, and Django arguably gives the application more control over the organisation of the "URL space" whilst leaving the retrieval of request parameters to the application, which more demanding Zope applications had to do manually anyway.

What I don't particularly like about Django and some other frameworks is the mandatory relational database system aspect. I've been involved in writing introductory material for frameworks with similar prerequisites before, and having people install, configure, tune and troubleshoot RDBMSs is a real turn-off for many newcomers (and an irritation even for many seasoned developers).

Flat View: This topic has 104 replies on 7 pages [ « | 2  3  4  5  6  7 | » ]
Topic: Discovering Bad Java Smells Previous Topic   Next Topic Topic: New Libraries coming ...

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use