Random notes from mg

a blog by Marius Gedminas

Marius is a Python hacker. He works for Programmers of Vilnius, a small Python/Zope 3 startup. He has a personal home page at http://gedmin.as. His email is marius@gedmin.as. He does not like spam, but is not afraid of it.

Sun, 04 Apr 2010

Review: Grok 1.0 Web Development

Disclaimer: I received a free review copy of this book. The book links are affiliate links; I get a small amount from any purchase you make through them.

Grok is a Python web framework, built on top of the Zope Toolkit, which is the core of what used to be called Zope 3 and is now rebranded as BlueBream. Confused yet? Get used to it: the small pluggable components are the heart and soul of ZTK, and the source of its flexibility. It's not surprising that people take the same approach on a larger scale: take Zope 3 apart into smaller packages and reassemble them into different frameworks such as Grok, BlueBream or repoze.bfg.

Grok 1.0 Web Development by Carlos de la Guardia

The Grok book by Carlos de la Guardia introduces the framework by demonstrating how to create a small but realistic To-do list manager. I like this technique, and it works pretty well. The author covers many topics:

Some important topics like internationalization, time zones, testing with Selenium, and (especially) database migration (which is pretty specific for ZODB) were not covered.

If you want to learn about Grok, this book will be useful, but there's a caveat: there's the usual slew of typographical mistakes and other errors I've come to expect from books published by Packt. It's their third book I've seen; all three had surprisingly high numbers of errors. Some had more, others had fewer. The Grok book was on the high side and the first one where I was tempted to record a "WTFs per page" metric. The mistakes are easy to notice and correct, so they didn't impede my understanding of the book's content. Disclaimer: I've been working with Zope 3 for the last six-or-so years, so I was pretty familiar with the underlying technologies, just not the thin Grok convenience layer. If minor errors annoy you, stay away. I haven't noticed any major factual errors, although there were what I would consider some pretty important omissions:

Overall, Grok is pretty nice, especially compared to vanilla Zope 3. However, when compared to frameworks like Pylons or Django, Grok appears more complex and seemingly requires you to do additional work for unclear gain. For example, chapter 8 has you writing three components for every new form you add: one for the form itself, one for a pagelet wrapping the form, and one for a page containing the pagelet. Most of that code is very similar with only the names being different. I'm sure there are situations where this kind of extreme componentization pays off (e.g. it lets you override particular bits on particular pages to satisfy a particular client's requests, without affecting any other clients), but the book doesn't convincingly demonstrate those advantages. Again, I may be biased here since I've been enjoying those advantages for the past six years, without ever having felt the pain of doing similar customizations with a less flexible framework. (It's a gap in my professional experience that I'm itching to fill.)

Update: some other reviews on Planet Python.

Update 2: Another review (well, part 1 of one, but I got tired waiting for part 2).

posted at 22:30 | tags: , , | permanent link to this entry | 3 comments
Thanks for the review! It's also interesting to see a list of important things that are missing in your opinion, so thank you for that.

One comment:

"bin/buildout is free to recursively remove anything under parts. Keeping your database there is fine only if you don't mind occasionally starting from scratch."

Grok 1.0 normally uses a filesystem layout where the ZODB is stored under 'var', and therefore buildout doesn't touch it as it isn't under 'parts'. (it used to be true in the older layouts)
posted by Martijn Faassen at Wed Apr 7 16:44:37 2010
Thanks for the review. Those are good points about the omissions. I think if I ever write another book on these topics I'll ask you to review before publication.
posted by Carlos de la Guardia at Wed Apr 7 17:54:50 2010
Martijn: I based my comment on the config file excerpt on page 166, "How blob support is configured in Grok":

  <blobstorage>
  <filestorage>
  path /<your directory>/todo/parts/data/Data.fs
  </filestorage>
  blob-dir /<your directory>/todo/parts/data/blobs
  </blobstorage>

Carlos: I have a slight flaw in my character, in that I assume "review" means "nitpick exhaustively about everything that isn't 100% perfect", and so I often forget to say anything about the good things.  Jeff McNeil said it best: you did a great job explaining a very complex software system.  I think the thing that impressed me most was the attention of detail to the example project, e.g. the AJAX bits.
posted by Marius Gedminas at Wed Apr 7 18:10:22 2010

Name (required)


E-mail (will not be shown)


URL


Comment (some HTML allowed)