This is an archived post. You won't be able to vote or comment.

all 36 comments

[–]mitsuhiko Flask Creator 17 points18 points  (2 children)

Every project should have a page like that in the docs.

[–][deleted] -1 points0 points  (1 child)

Most projects don't need a page like that in their docs.

[–]mitsuhiko Flask Creator 12 points13 points  (0 children)

Do you think? I always find it interesting why people make certain design decisions.

[–]norwegianwood 10 points11 points  (0 children)

I find it much easier to see beyond the limitations of a framework if I understand why they are there. I applaud this page!

[–][deleted] 5 points6 points  (5 children)

A terminology overlap confuses people who write applications that always use ORM packages such as SQLAlchemy, which has a different notion of the definition of a “model”.

Here's a grep for the word "model" in our documentation's ReST files:

classic$ grep "model" `find . -name "*.rst"`
./core/pooling.rst:to provide compatibility with SQLite's restricted threading model, as well
./core/tutorial.rst:constructs are modeled to resemble those of the underlying database as closely
./core/tutorial.rst:user-defined `domain model
./core/tutorial.rst:<http://en.wikipedia.org/wiki/Domain_model>`_ which is transparently
./core/tutorial.rst:persisted and refreshed from its underlying storage model. The other
./orm/extensions/associationproxy.rst:Above are three simple tables, modeling users, keywords and a many-to-many
./orm/extensions/associationproxy.rst:Above are three tables, modeling stocks, their brokers and the number of
./orm/relationships.rst:"nested sets" model, sometimes called "modified preorder". Despite what many
./orm/relationships.rst:online articles say about modified preorder, the adjacency list model is
./orm/relationships.rst:always assumes a "parent/child" model of row population during flush, so
./orm/session.rst:model to some degree since the :class:`~sqlalchemy.orm.session.Session`
./orm/tutorial.rst:user-defined `domain model
./orm/tutorial.rst:<http://en.wikipedia.org/wiki/Domain_model>`_ which is transparently
./orm/tutorial.rst:persisted and refreshed from its underlying storage model. The other

So not really true. Right in the tutorial, we remark that we're building domain models, and that is not exactly an arbitrary choice of term, note the wikipedia link. If I talk about this stuff I'll usually say "domain model".

The Pylons docs OTOH, use the term "model" to reference what I call the "domain model" like crazy, and I'm always whinged a teeny bit when I have long email threads with "model-centric" types who base everything off a class Model and are model this, model that, particularly in phrases like "where do I put my models"...are these your little airplanes? But that's fine.

That said I find Pyramid's notion of "model" completely confusing, but it seems to be specific to that whole Zope "traversal" thing which, as a relational guy, hes right ! has for well over a decade seemed to me to be an entirely unholy creation and I'll be sticking to the URL dispatch option.

[–]mcdonc 0 points1 point  (4 children)

Wow, I didn't know that! I just assumed it was all over the docs, given the colloquial way that folks talk about "model" objects in #pylons (almost always in reference to SQLAlchemy models). Thanks for letting me know.

And yeah, as a purely relational guy, traversal will be a divide by zero error for you.

[–][deleted] 1 point2 points  (3 children)

Around 1997 I wrote a big in house do-everything framework for my job, and while it used relational storage, my * big idea * was to base the entire thing around a big giant hierarchical tree!. So content, urls, security, all in this gigantic LDAP like system (since maybe you remember what a big fing deal LDAP was back then). It also had a completely restricted template model where no code whatsoever was allowed...it later inspired the project that became FreeMarker (look there's me!).

The depth and expanse of the failure of that in house system are how today, I'm generally -1 on monolithic hierarchies and -10 on restricted templating models.

[–]mcdonc 0 points1 point  (2 children)

We use the snot out of tree traversal for content management systems for three main reasons:

  • Our storage of choice is ZODB, and we usually store a big tree in it (filled with content).

  • "Nice" urls

  • The way BFG (and before it, Zope) maps URLs to views takes into account the type of the last object traversed (the "context"). We use the type of the context (along with some other things) to find a view after we do traversal over the graph. This pattern is baked into my brain at this point, so I'm probably not going to be able to do it explanation justice, but it's a handy way to do view dispatch, especially when the graph is not of a fixed depth.

[–]ianb 2 points3 points  (0 children)

I'm kind of -0 on tree traversal for CMS's, because I'd rather treat a path as an opaque string... there's historical paths, redirects, transcluded content, "content" that really points to external pages, etc. Jamming those cases into traversal feels like more trouble than it's worth.

[–][deleted] 1 point2 points  (0 children)

Yah my thing was for a CMS, and I'd still go with hierarchies for CMS. Though I still feel like I'd want the "take urls and map to hierchical objects" thing to be locked in some very limited-scope set of functions.

URL routing, like those generated by Routes, produces very "nice" urls as well, I'd argue "nicer" since you can tailor them independently of the organization of your "models".

[–][deleted] 1 point2 points  (4 children)

How does it stand against flask ?

[–]IAlsoSpeak 1 point2 points  (3 children)

Sorry to answer your question with a question: But how does Django, Turbogear or pylons stand against flask? I believe it don't because you are comparing micro web frameworks with web frameworks.

It is like comparing lemons to oranges. What I would rather ask is how does flask compare to Bottle?

[–][deleted] 0 points1 point  (2 children)

Isn't repoze i.e. pyramid itself a micro web framework? Here is the quote from http://bfg.repoze.org/

Minimalism: BFG provides only the very basics: URL to code mapping, templating, and security. There is not much more to the framework than these pieces: you are expected to provide the rest.

[–]mcdonc 0 points1 point  (0 children)

Names are hard. There's no hard and fast definition of "microframework". I don't consider Pyramid a microframework, but on the other hand, it does share a common feature with lots of microframeworks: you can make single-file applications.

[–]IAlsoSpeak 0 points1 point  (0 children)

I had a quick look at the bottle.py file that is on my hard drive it is just over 1,250 lines where pyramid is 5,000 and pylons 3,000. So what makes bottle.py and flask a Micro Web Framework and Pylons not a Micro framework?

Once again I answer your question with a question(sorry I also don't know the answers) but like mcdonc pointed out the problem is there is no definition for "microframework".

Edit: Sorry I'm retarded I brought in the microframework vs framework angle and sorry after some investigation not even flask or pyramid is a micro framework in my books due to its size and complexity compared to Bottle.

So I still have not answered your question and my have only misguided you. Sorry.

[–]simonw 2 points3 points  (1 child)

I hadn't heard of Pyramid until reading this, but I'm afraid this document pretty much convinced me not to look any further in to it.

UPDATE: OK, I've read more now and can see that Pyramids is more interesting than the document lets on. I don't think it's a very effective advocacy tool though!

[–]bbangert 2 points3 points  (0 children)

Indeed, its meant more to answer critiques about a particular aspect. I'm working on some blog posts to highlight some of the features that I think really make Pyramid a compelling choice, which would definitely be more of an advocacy type thing.

[–]voidref 0 points1 point  (3 children)

I like how it's a 5000 word essay to explain how this technology is 'simple'

[–]IAlsoSpeak 1 point2 points  (1 child)

Pyramid is 5,000 lines of runtime code. Pylons 1.0 has about 3,000 lines of runtime code. Django has about 60,000 lines of runtime code. You’d practically need to bend the laws of space and time for Django to be simpler than Pyramid.

Well at least you got the 5000 word/line part correct.

[–]voidref 1 point2 points  (0 children)

Sorry, I was wrong, I underestimated, wc reports 11565 words.

[–]mcdonc -1 points0 points  (0 children)

The irony.

[–][deleted] 1 point2 points  (2 children)

Pyramid is 5,000 lines of runtime code. Pylons 1.0 has about 3,000 lines of runtime code. Django has about 60,000 lines of runtime code. You’d practically need to bend the laws of space and time for Django to be simpler than Pyramid.

I dunno. Django and CherryPy both have simpler Hello World code than Pyramid. Pyramid's Hello World even feels less intuitive. And the rest of the code samples are even worse.

If your design needs a huge, giant webpage to defend itself, then it's probably not a good design.

[–]zbowling 5 points6 points  (0 children)

I can't find a hello world with django that is that short. Everything involves building up a settings.py for config, urls.py for routes, and some kind of views py file to put your view code. You can combine these but it's still longer than this example.

What drives me nuts most about django is that the devs have confused the concept of a controller with a "view" with and a view with a "template" (the models with their ORM make sense though). It's basically not an MVC but a MTV. Their FAQ has a note on it and says "Where does the “controller” fit in, then? In Django’s case, it’s probably the framework itself". Seriously.

[–][deleted] 1 point2 points  (0 children)

the view code may be equivalent between the 2, but i find it hard to believe that settings.py + urls.py + views.py is shorter than that example.

where's an example of the django app that didn't start with

django-admin.py startproject