The Artima Developer Community
Sponsored Link

Weblogs Forum
Please Teach me Web Frameworks for Python!

104 replies on 7 pages. Most recent reply: Sep 29, 2008 1:31 AM 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 | » ]
Harry Fuecks

Posts: 875
Nickname: hfuecks
Registered: Sep, 2004

Re: Please Teach me Web Frameworks for Python! Posted: Jan 27, 2006 6:44 AM
Reply to this message Reply
Advertisement
Second that for web.py (http://webpy.org/), for starters as it's just a single Python script. Also it's the REST style web.py encourages ( methods named GET, POST etc. ) which very few frameworks have grasped.

Re your requirements;

# independence from web server technology.

Basically yep. It defaults to BaseHTTPServer but automatically detects FASTCGI if it's a around.

# Templating with reuse.

It points you in the direction of Cheetah templates, which have re-use in a way that parallels OOP.

# Cookie handling. For authentication, preferences, sessions, etc.

There you have to use other Python libraries - you're probably heading in this direction: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/325484

# Query parsing. The bread and butter of form handling.

Yep

# URL dispatch.

Yep

Paul Boddie

Posts: 26
Nickname: pboddie
Registered: Jan, 2006

Re: Please Teach me Web Frameworks for Python! Posted: Jan 27, 2006 7:07 AM
Reply to this message Reply
You write: "Independence from web server technology. You should be able to run the same application under Apache, as a CGI script, as a stand-alone server (e.g. BaseHTTPServer or Zope's or Twisted's built-in server), etc. (The Java Servlet API does this really well IMO -- I used it at Elemental.)"

If you want something like the Java Servlet API, with a certain level of independence from Web server technologies, have a look at WebStack (http://www.python.org/pypi/WebStack). It doesn't address every issue of Web application architecture, but it is a step above CGI/WSGI and you can use fairly conventional Python semantics to extend your application to use templating, persistence, and so on. (A rough example of that kind of approach is XSLTools: http://www.python.org/pypi/XSLTools)

As I've stated in other forums, WSGI provides useful plumbing for Web applications but fails to address the kind of code that developers will actually be writing. If you're considering improving the Web development situation in Python, I'd recommend banging some heads together and getting the Web-SIG to deliver what it promised two years ago.

Balazs Fejes

Posts: 1
Nickname: fb2
Registered: Jan, 2006

Re: Please Teach me Web Frameworks for Python! Posted: Jan 27, 2006 7:35 AM
Reply to this message Reply
+1 for TurboGears. I think it needs like 3 more months to be really good, but it is very useful now as it is.

Lorenzo Bolognini

Posts: 2
Nickname: lbolognini
Registered: Jan, 2006

Re: Please Teach me Web Frameworks for Python! Posted: Jan 27, 2006 8:19 AM
Reply to this message Reply
I think you want:
- CherryPy
- Cheetah (templating language)
- SQLObject as an ORM, if you want one

Lorenzo

Richie Hindle

Posts: 3
Nickname: richieh
Registered: Jan, 2006

The Python FAQ Posted: Jan 27, 2006 8:36 AM
Reply to this message Reply
> the Python FAQ [...] (Is anybody still using it?!?)

Yes! We're using it for our internal FAQ system, and it does the job very well.

Jonathan Ellis

Posts: 7
Nickname: jbellis
Registered: Aug, 2005

Re: Please Teach me Web Frameworks for Python! Posted: Jan 27, 2006 8:49 AM
Reply to this message Reply
A word of caution about SQLObject -- every developer I know who has tried to use it for a nontrivial project, including myself, has ended by giving up in frustration. It's very half-baked in a lot of ways, not least its transaction support. I think most of this stems from its desire to treat an RDBMS as a slightly retarded object store. Which is all fine... until it isn't.

I recommend PyDO2 as an orm for smaller projects and SQLAlchemy for larger ones (requires more setup, but is ultimately more powerful).

(BTW, the Utah Python User Group's next meeting (Feb 9) will cover more solutions to PyWebOff using some of these toolkits. You're all invited. :)

Tim Parkin

Posts: 3
Nickname: timparkin
Registered: Jan, 2006

Re: Please Teach me Web Frameworks for Python! Posted: Jan 27, 2006 9:26 AM
Reply to this message Reply
I have to agree with Terje Slettebø about xml being the most appropriate syntax to add templating directives to a html (xhtml) document.

Our company spent a long time looking for the most sensible templating language and the following opinions were formed

1) If you want any form of logic in your templating, it should be written in the native language that you are programming in.

2) mixing python and xml in the same file is bad. Mixing it on the same line of a file is evil.

3) A template file should remain valid xml (for various reasons)

4) writing programming languages in xml is evil.

From these opinions, the following was concluded

1) templating directives should only mark positions and ranges within the template.

2) the templating framework should allow the manipulation of the above directives. e.g. inserting new xml into certain places, extracting fragments to insert elsewhere, or to be transformed etc.

3) The templating language should help you construct urls, escape strings, etc.

Nevow just happened to match most of our requirements (we were initially looking at tal-like templating).

I'd be interested if you have different initial opinions about how an 'ideal' templating system would look (I'll ignore the framework thing for the moment).

Tim Parkin

ps. here is an example of a nevow list as cgi

#!/usr/bin/env python
print "Content-type: text/plain\r\n\r\n",

from nevow import rend, loaders

mytemplate = """
<html xmlns:n="http://nevow.com/ns/nevow/0.1">
<body>
<ul n:data="mylist" n:render="sequence">
<li n:pattern="item" n:render="myitem"><n:slot name="name" /></li>
</ul>
</body>
</html>
"""

# define page
class simpleList(rend.Page):
# load template
docFactory = loaders.xmlstr(mytemplate)

# define data
def data_mylist(self,ctx,data):
return ['tim','matt','charlotte','damian']

# fill slots
def render_myitem(self,ctx,data):
ctx.fillSlots('name',data)
return ctx

print simpleList().renderSynchronously()


Stan is also quite useful if you want to mix html with your python code. It may seem a little hacky at first but it's an enormous timesaver and results in very clean code (http://www.kieranholland.com/prose/meet-stan/)

Adrian Holovaty

Posts: 5
Nickname: holovaty
Registered: Jan, 2006

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

Definitely check out Django once its "magic-removal" branch is merged. For a preview of those (quite large) API changes to Django, see here:

http://code.djangoproject.com/wiki/RemovingTheMagic

Adrian Holovaty

Posts: 5
Nickname: holovaty
Registered: Jan, 2006

Re: Please Teach me Web Frameworks for Python! Posted: Jan 27, 2006 9:55 AM
Reply to this message Reply
Regarding Django's template language not being Pythonic: Being Pythonic wasn't a goal. We wrote that template system with the design decision that non-programmers (i.e., Web designers who know HTML and don't know Python) should be able to use it.

This has proved to be a great strategy, because we've had entire, complex sites built using Django templates by designers who don't know Python. Examples: visitlawrence.com, kkcscountry.com, ljworld.com.

The way I see it, it's more acceptable to give programmers a negligible learning curve for learning template languages, than to give Web designers the learning curve of learning a programming language. Not to mention the security implications of allowing pure Python code in templates.

The Ruby on Rails people are realizing this, and they've made a template language that closely mirrors Django's: http://home.leetsoft.com/liquid/

Huy Do

Posts: 1
Nickname: hqd
Registered: Jan, 2006

Re: Please Teach me Web Frameworks for Python! Posted: Jan 27, 2006 10:19 AM
Reply to this message Reply
Mate, I've tried most and most just get it the way without helping much but with the most trivial of tasks; by providing the most overhyped feature i've ever seen "scaffolding/crud".

My current choice is "myghty".
1. You beaut python language templates. No relearning of obscure syntaxes. Everything works as expected eg. Its a dict, use it like a dict in the template. Fast. Only one gripe which is the <%args> tag but theres a very nice way around that.
2. Just as easy to use string interp or (put your desired template here) without losing out on anything. Mix and match is also good to go.
3. the most flexible url mapping features i've come across from the very simple, i.e auto map entire module,function,class,method to urls to the more complex routes module (i.e regex) so it can grow with you as you need to be more clever.
3. Controller code can be written as simple python functions, as object methods or anything else that pushes your buttons.
4. Choose your own sql access method without any penalties. My pick and better then anything i've ever come across is SqlAlchemy. Again for the same reasons as myghty. You can use it for simple things but it can grow with you as you need to. And did I mention that it was fast.
5. Supports everything you listed.

I have no link to any of these projects except as a very happy camper. I hope they don't become too popular and caving into the rails mob mentality (it's nice that the pylons spin off project is very separate).

David Stanek

Posts: 2
Nickname: dstanek
Registered: Jul, 2005

Re: Please Teach me Web Frameworks for Python! Posted: Jan 27, 2006 10:22 AM
Reply to this message Reply
I have really been liking TurboGears. I have been for several months now and am very pleased with it's leaps and bounds.

Mario Ruggier

Posts: 4
Nickname: mr17
Registered: Jan, 2006

Re: Please Teach me Web Frameworks for Python! Posted: Jan 27, 2006 10:49 AM
Reply to this message Reply
If you liked Quixote, and you like its PTL templating, and you spent time at Zope, then it is mho that you should definately look at the QP web application framework [1] ideally intended for applications that use Durus for persistence and QPY for formatting. Durus is a simple object database that is a joy to use, and QPY is essentially PTL gone unicode -- and is really fast templating btw. In all aspects it is about as pythonic as one can hope for. Out of the box you get user management, sessions, authentication (3 flavours, http basic, digest, and form login). Choices made by the framework make all this easy, but there is absolutely no lock-in, and you can use whatever ORM, relational db, templating, etc, that you may wish and be willing to put in the extra effort to work with.

Plus, the publicity and hype about QP is non-existant ;-) Those guys, Neil, David, Roger, and others, seem to just be perfectly satisfied to produce superb software... for anyone who wants to use it. So, the readme is about all you get, unless you want to invest a couple minutes in installing it, and then you can play with 3 demo applications, using a very handy utility script to start/stop the db and web apps, that may run behind apache/scgi, cgi, or standalone, http or https.

mario

[1] http://www.mems-exchange.org/software/qp/

Mike Coleman

Posts: 2
Nickname: mkc
Registered: Jan, 2006

Re: Please Teach me Web Frameworks for Python! Posted: Jan 27, 2006 10:59 AM
Reply to this message Reply
I think this is a problem for Python, right now. I've been using Python avidly (some might say rabidly) for all of my primary work for the last five or six years. I do some web stuff and have tried several of the frameworks over time (basic CGI, Quixote, Zope, TurboGears, Webware) and looked at most of the others. None of it really seems ready for prime time yet.

I most recently had high hopes for TurboGears, and I hope that with a burst of activity it will come along. But right now it's very frustrating to use, particularly sqlobject.

I never would have imagined it, but I find myself trying Ruby on Rails. I, too, was repelled by Ruby's sigils, but after looking closely, I see that they're not Perl's horrid type sigils, but rather indicate scope, which I suppose is not so different from the way that Python uses "self.". Anyway, so far at least, RoR's documentation is looking pretty good.

I might not be doing this but for other problems I've been experiencing with Python (related to getting bugs/misfeatures fixed), but that's another essay.

Mike Coleman

Posts: 2
Nickname: mkc
Registered: Jan, 2006

Re: Please Teach me Web Frameworks for Python! Posted: Jan 27, 2006 11:03 AM
Reply to this message Reply
I have a lot of respect for SqlObject's author, but I also ran into a lot of annoying problems while trying to use it in TurboGears. If I had more time, I'd try to fix things, but for now I'm continuing to look around. (Currently trying RoR, of all things...)

Holger Froebe

Posts: 1
Nickname: onko
Registered: Jan, 2006

Re: Please Teach me Web Frameworks for Python! Posted: Jan 27, 2006 11:19 AM
Reply to this message Reply
<ducks>
Beat me for that, but I'm convinced
Zope3.2 is by far the best professional
python web framework - heck, I think its the most
mature python component framework upto date.
Which adds up the bonus of (re)using your
stuff outside your webapplication.

I realized some web/offline projects with it
and the longer I work with it the more
I learned to appreciate its strengths
in clearly defining responsibilities of
objects/components and strongly appreciating
reusability.

Sure, if you don't like XML
for ideological reasons, then Zope3 is evil.
But if I want to get a serious project done,
I don't care about ideology, but look
for a pragmatic solution. And under
this premise Zope3 is my platform of choice.


For integrating SQL databases:
I second the opinion (from painful experience)
that SQLAlchemy (or PyDO2) is better
than SQLObject.

<ducks again>

Flat View: This topic has 104 replies on 7 pages [ « | 1  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-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us