Live data from Hacker News

Poll: Pythonic startups: what web framework do you use?

news.ycombinator.com

61–70 of 76 posts

Re: Poll: Pythonic startups: what web framework do you use?

#61
post #55
post #40

Earlier quoted context omitted.

I want to preface this by saying that Django isn't bad. It's really good. However, there are some maddening things. For example: In Rails, you can say Article.find(:all, :include => :comments) and that will get you the articles with their comments. In Django, you can say for a in Article.objects.all(): a.comments #hits the database again! argh! Before you say, "Django has select_related() which does the same thing as…

Your first issue is incorrect. You can easily accomplish the query with one sql hit. The extra() command would work if your foreignkey was defined in the comments model.

Nope. extra() doesn't allow one to do that. extra() can be used to populate an attribute. So, say I wanted to do a comment count I could say

  Article.objects.all().extra(select={'comment_count': 'SELECT count(*) FROM blog_comment WHERE blog_comment.article_id = blog_article.id'})
But I can't populate a list of comments objects onto it.

I've talked to Malcom about it (who wrote the QuerySet Refactor branch - or at least a substantial portion) and it's a known deficiency. Basically, the issue is two-fold. First, no one has stepped up to write the code that would make select_related() work in that fashion. Second, people want the implementation to disallow certain bad situations.

The first part is self-explanatory: select_related() should be enhanced to support that, but someone needs to write the code. The second part isn't as much, but it's more interesting.

Let's say you execute this query:

  SELECT * FROM articles LEFT OUTER JOIN comments ON comments.article_id = articles.id
How many rows will you get from that? You'll get somewhere in the vicinity of the number of comments (adding a row for any article without comments). Suffice it to say, the results set grows linearly in proportion to the number of articles and comments.

Now let's say we have this:

  SELECT * FROM articles LEFT OUTER JOIN comments ON comments.article_id = articles.id LEFT OUTER JOIN votes ON votes.article_id = articles.id
So, we have our article with comments, but also votes now. So, let's say we want to get just one article that has 100 comments and 200 votes. How many lines will that return? In the original SQL query, we would have seen 100 lines (one for each comment) which would have been manageable. Here, we get 100 * 200 lines back. That's 20,000 rows to parse to build a single Article object!

So, the Django folk aren't into letting you just hang yourself out to dry like that. There have been proposals to limit it in ways that wouldn't let you do that, but it's really just something genuinely missing and there isn't a way to do it other than running looped queries or doing something ugly.

extra() doesn't do the same thing as select_related(). I'm not saying that doing ORM over multi-valued relationships is easy or that you can't execute queries that are really bad doing them, but it still means that there isn't support for a pretty basic function.

Re: Poll: Pythonic startups: what web framework do you use?

#64
post #59

Earlier quoted context omitted.

Shit didn't work. Often something in the DB layer, sometimes just getting a "hello world" in a browser.

FWIW, that isn't a fault of the framework per se; I have had no problems with Pylons doing something it shouldn't have done. You have to understand what the code is doing, and each framework has a different learning curve, but in my experience Pylons is as usable, expressive, and understandable as Django.

I'm certainly just a single data point. The difference between Pylons and Django could have been documentation alone, and could have been unique to me.

I kind of doubt that though.

Re: Poll: Pythonic startups: what web framework do you use?

#65
post #54

Earlier quoted context omitted.

Grok's main value, to me, is to interact with larger Zope applications without having to deal with all of the mental overhead that Zope entails. You can also reap the great benefits of the ZODB very easily with Grok alone. Grok is very easy to learn, and was designed by people that really know what they are doing with regard to Python web app development.

Thanks, I've heard Zope is huge and that must be the mental overhead you were referring to. I take this to mean that it was at once a large project, but jusdging be the 124 to django and 4 for Zope + Grok I take it that it has fallen out of favor. Why? Does it make anything too difficult? Is it too closely married to ZODB, ie. are there problems with ZODB?

Zope's main problem is one of branding. Zope3 is really an entirely different beast than Zope2, but the sins of Zope2 (chiefly a monolithic and deeply intertwingled codebase that meant you mostly had to swallow the kool-aid to use any of it) have continued to plague Zope3's acceptance, even though Zope3 doesn't have the same problems.

Still, Zope3 requires a bit more mental overhead due to the infrastructure it contains meant for handling extremely complex application domains and use cases with relative ease. For example, none of the other frameworks has an authentication and authorization implementation that is anywhere near Zope's in terms of pluggability and flexibility. Very useful if you need to build an intranet app that gathers user login credentials from several systems, and their permissions from some other system, but almost entirely useless if you're building a Web 2.0 app where content is strongly owned by an individual user who only needs to grant viewing permissions to other users.

At least, until you want to add group permissions, role-based security rules, or need to alter permissions based on workflow state, and be reasonably sure that your solution is actually secure.

The Zope universe is full of reusable optional libraries that solve problems that are this complex, and the framework itself has to have some additional complexity in order for it all to plug together in a reasonable way. This extra level of complexity is represented in the Zope Component Architecture (primarily zope.interface and zope.component). To handle the 'plugging together' part as configuration rather than code, we also have an XML-based configuration language called ZCML.

To people who think that they don't need that complexity because their problems are simple, Zope seems like overkill. But then they end up re-inventing wheels such as access-control-lists, and not necessarily doing it well at all.

Re: Poll: Pythonic startups: what web framework do you use?

#66
post #22
post #12

Earlier quoted context omitted.

Have you listened to Cal Henderson's friendly rant against Django from a scalability perspective? http://www.youtube.com/watch?v=i6Fr65PFqfk For example, did you modify the source to support multiple databases for read/write? Or is that not an issue and it's OK that it's coming later in the framework's roadmap?

As I see it, if we get enough traffic to be worried about scaling issues we'll deal with it then. Django isn't terribly designed and going in and hacking multi-db and sharding in should take less than a week from a competent developer. Discussing this before starting a startup sort of feels like trying to figure out how to do salary for hundreds of employees before getting your first one.

We're running multiple databases, live, with the Django ORM. Confirming that it's not very hard.

Re: Poll: Pythonic startups: what web framework do you use?

#68
post #61
post #55

Earlier quoted context omitted.

Your first issue is incorrect. You can easily accomplish the query with one sql hit. The extra() command would work if your foreignkey was defined in the comments model.

Nope. extra() doesn't allow one to do that. extra() can be used to populate an attribute. So, say I wanted to do a comment count I could say Article.objects.all().extra(select={'comment_count': 'SELECT count(*) FROM blog_comment WHERE blog_comment.article_id = blog_article.id'}) But I can't populate a list of comments objects onto it. I've talked to Malcom about it (who wrote the QuerySet Refactor branch - or at leas…

Wow, that's an excellent response. You're right. I can't think of any means of easily accomplishing that - if at all; which I find odd, because I would think that would occur at least a few times.

Re: Poll: Pythonic startups: what web framework do you use?

#69
post #66
post #22

Earlier quoted context omitted.

As I see it, if we get enough traffic to be worried about scaling issues we'll deal with it then. Django isn't terribly designed and going in and hacking multi-db and sharding in should take less than a week from a competent developer. Discussing this before starting a startup sort of feels like trying to figure out how to do salary for hundreds of employees before getting your first one.

We're running multiple databases, live, with the Django ORM. Confirming that it's not very hard.

Ah I knew there was the checkin, I wasn't aware it was currently useable. Thanks for the info, I will have to check it out.
Post reply on HN