Tuesday, March 23, 2010

Review: Grok 1.0 Web Development

Those who know me technically know that I'm big into the TurboGears Python web development framework. Despite my affinity for al things TurboGearish, it's often useful to spend some time studying other frameworks to see the different design decisions they made, and to maybe just get ideas on how you can improve your own chosen framework. It was with that mindset that I sat down to read Grok 1.0 Web Development by Carlos de la Guardia.




For those who are unfamiliar with Grok, Grok is a Python web framework built on top of the Zope 3 toolkit that endeavors to make Zope more accessible to those who are not already experts in the deep magic of Zope. One of the problems with a layer like Grok is that sometimes Zope leaks through into your code. In such cases, it's nice to have a guide for where Grok starts, where Zope begins, and how they work together. This book can provide just that, as well as giving someone who may be new to Python web development a pretty good tutorial and head start on Grok development in particular, and Python web development in general.


tl;dr Summary


This is a good book. It's not "OMG I need to drop all my TurboGears work right now and rewrite everything in Grok" good, but it gives you a good feel for the Grok framework and the Zope toolkit underneath it without being too overwhelming. If you want to learn Grok or Zope web development, or if you just want to see how someone else did it, I'd say this is a good book to read. If, however, you want an architectural description of Zope, or if you're brand-new to Python, HTML, CSS, and Javascript, this probably isn't the book for you.


Synopsis


This book follows a running example of building a to-do list manager, which I think is a great way to make the daunting world of Zope more accessible to us mortals. By building the app from its barely-on-the-web-no-persistence-at-all roots to a multi-user, multi-project list manager with full security, a heterogenous database backend, etc., the book introduces Grok and Zope concepts in a logical and easy-to-follow way.


The book starts in chapter 1 with a high-level overview of what makes Grok Grok. This is nice if only to give you your bearings before diving into the more tutorial-oriented remainder of the book. Chapter 2 leads your through Grok's installation process including just a bit about Buildout, Zope's packaging and distribution system. Chapter 3 launches into Grok views, including Zope Page Templates (Grok's templating language), form handling, and static resources.


In chapter 4, the Zope Object Database (ZODB) is introduced, as you add persistence to your to-do list application. Some of the "magic" of Grok is also revealed, including how Grok magically knows what views go with what models and what templates. More importantly, it lets you know how you can override this default behavior. Chapter 5 returns to the topic of forms and introduces the grok.EditForm, Grok's solution to automatic form generation and validation.


Chapter 6 introduces the Catalog, which provides search capabilities to Grok applications. Chapter 7 moves on to security, including authorization and authentication. In this chapter, the author even leads you through adding your own authentication module to the todo-list application.


Chapter 8 presents the Grok Viewlet architecture, a set of tools that let you easily build complex templates from simple parts. This is something that in my experience very few frameworks get right. I will definitely be stealing some ideas from here for TurboGears ;-).


Chapters 9 and 10 return to the topic of persistence, with a more detailed discussion of the ZODB in chapter 9 and a description of how you can seamlessly integrate SQLAlchemy and relational databases into a Grok application, a topic near and dear to my heart.


Chapters 11 and 12 go into a good bit of detail of the fundamental concepts behind Grok and Zope, including Zope interfaces and "grokkers" (the things that read the little Grok decorators that make everything so much easier than straight Zope). If you want to know which chapters you can skip when getting started with Grok, it's these two.


Chapter 13 describes Grok's support fortesting and debugging which, like so much of Zope, is really well though out and cohesive once you "get it." Chapter 14 concludes the book with a discussion of deployment and scaling Grok applications, including deployment behind Apache and ZEO (load-balancing) deployments. Again, for the beginner, this is a chapter to save for later.


Conclusion


Overall, I think this is a well-written book. There are a few typos in some of the examples, but it's easy enough to make the corrections in your head, and I didn't find them distracting at all. The book flows well, and was written at a pace that I enjoyed. (For an excerpt to judget for yourself, here's Chapter 5: Forms Again, I'm not going to drop all my TG stuff quite yet, but I do think Grok is worth a second look.

No comments:

Post a Comment