Ask Hacker News: What Python web framework should I use?
What python web framework would you guys recommend for smaller web projects? Examples would be a small blog engine, simple news site etc. Django seems quite huge for simple projects, so recommendations are more than welcome.
40 comments
[ 2.8 ms ] story [ 83.0 ms ] threadBtw, I should add that I'm asking from the perspective of somebody moving towards a Pythonic framework. I've spent the better part of today learning Python, and so far I love it!
If you learn Django, I'm sure you won't regret it. I don't think it's "huge" at all: it's compact and usable.
PROS: * Light and fast, * Really flexible, * Really easy to learn, * Easy to install, * Nice error reports (mostly copied from Django), * No database ORM
CONS: * No database ORM, just some helper functions: insert(...), update(...), select(...), etc. You must also build the DB tables by yourself. * Limited documentation.
http://groups.google.com/group/webpy/browse_thread/thread/2f...
If he couldn't spot that when he posted, I don't trust him to spot any other problems with web.py
Then it hit me.
He was suggesting you give the pickled object back to the client in the session cookie and load whatever the client sends later right back into the interpreter. Whee!
I've done that with signed cookies.
Think HMAC, though I used two completely different keys, rather than generating them from one key, added an optional step of appending the client's IP address after the first hashing (with the first key) and before the second one.
(The second hashing in HMAC is designed to prevent collision attacks (even on weak algorithms like MD5), since you'd essentially have to find a fraudulent input that collides twice: once when hashed, and once more when its hash is hashed).
My implementation also allowed the data to span an arbitrary number of ~4kb cookies). Firefox maxed out at around 0.5MB, though if you're using that much session data, you may want to rethink your app design... ;)
My only cons (last I checked):
- Connecting to multiple databases is kind of a hack.
- Depreciation of cheetah over aaron's templating system.
So, it's just about perfect for me.
I am not sure it is by laziness, or it is purposely done to scare n00bs away from it.
It's a pitty when somebody takes the time to built a decent and useful framework, but just hinders its adoption, by not going the extra mile and providing good documentation.
pylons: didn't really like the lack of decorators, didn't seem to be an ORM of choice, docs looked weak although the wiki was well stocked with recipies
django: really well documented. Seemed to be HUGE and I felt intimidated by it. It wasn't clear to me I could strip it down to what I needed. Didn't seem very modular, you can only use the Django ORM and templating engine.
web.py: Far to simple for my needs, you need to build nearly everything from scratch, simple to learn because there is nothing there!
I chose Turbo Gears because it seemed easier to chose the components you want to use. The idea that the TurboGears community picks best of breed python components and integrated them really appealed to me. This is both good and bad but in general I think it's been good for the project.
A year later and I haven't been disappointed. The TG community is really friendly as well :) TG is working with the pylons team for the next version of TurboGears and I know there has been a lot of code sharing between the groups.
That's my 2p, good luck.
Very common misunderstanding. You can use Django with SQLAlchemy (I have done in the past). You can use Django with Genshi, or Cheetah, or whatever template engine you like (I would strongly recommend using something like Genshi for outputting XML). It's usually better to stick with the Django ORM though as it will let you use many of the excellent extension applications for Django (such as django-mptt, django-tagging or the Django admin package). The same is not true for the Django template system - replacing it with something else has no disadvantages at all that I can think of.
* A RSS-rewriting, caching "proxy" for the News.YC feed
* A search engine for 2 gigs of email, going back to 1995
* A customized CMS-like app
* And now, my blog, which I'm almost done writing; I keep making changes to the architecture.
TurboGears 2, which some have recommended, is being built on top of Pylons.
Don't get stuck in paralysis through analysis. Find something that seems good and go with it.
For a simple blog you would need to write only a few views and templates, and then I would use the the built-in admin system to manage the content. Same sort of situation for the simple news site.
I always get flamed for suggesting to not reinvent the wheel, but if you want to do build something like a quick news site, why not leverage all the pre-existing work you can. Technology is not your differentiating factor. /rant
I'm contemplating to skip Zope3 to learn Plone. I'm also tinkering with the idea of purchasing Plone 3 book by Martin Aspelli. I heard the book is good and it gives you enough information about Zope3 to learn Plone.
http://thingsilearned.wordpress.com/2007/08/14/zope3plone-to...
Its a great CMS with a lot of awesome features. Its just incredibly difficult to pick up and work with, especially in its current state.
Although I agree, Django is really your best choice here.
It's very simple, yet powerful enough to let you do pretty much anything you need to.
Edit: I started with Pylons but was simply overwhelmed by the complexity. I checked out but didn't use TurboGears and Django so I don't have to much to say about them. web.py is nice, but it's immature and some things don't seem to work the way they should.
So I rolled my own (if you can call it that) using the db module from web.py along with Mako and mod_python.
Yes before the WSGI zealots freak out let me say that it is NOT a WSGI solution but I could care less. It just works.