I'm in the process of moving my blog to http://www.jmcneil.net, please update links & readers if you're subscribed to mcjeff.blogspot.com. Comments disabled on this version, but allowed at http://www.jmcneil.net/2010/03/review-grok-1-0-web-development/.
If there is one thing that the Zope community takes a lot of heat for, it's complexity. More accurately, the quality and coherence of the documentation regarding that complexity. Enter
Grok. Grok is an attempt at reducing the complexity and barrier to entry that usually surrounds Zope application development.
I've just finished reading Mr. Carlos de la Guardia's
Grok 1.0 Web Development and there are a few things I know I'm sure of.
- Zope is still very complex. Need it be? That's a topic for another post.
- ZODB is cool no matter how you look at it. Unless I'm missing something, it's surprising that it isn't used in more applications as a standalone object store. Reading this book has put that on my list of things I intend to try. It seems as though it ought to be the "SQLite" of the NoSQL movement from a Python standpoint.
- The Zope Component Architecture (ZCA) is also just as cool as ZODB, and the same question applies. Why don't we see this in more places? Maybe this is already taken place, but I would love to see those core Zope components really put on a platform of their own.
All of that said, there's clearly a place for the ZCA. Don't use it if you're writing a script to automate a simple task. However, it might fit in well in a large enterprise-y Python environment. My irritation? When writing a script to automate a simple task I need to care about adapters, utilities, interfaces, and registries. If it's not wanted, it really can make the automation of a systems administration task overly complex.
Now that my personal opinion is out of the way, let's take a deeper look at the book. We'll get the plusses and minuses out of the way nice and early as I tend to be long winded.
The Positives
Carlos did a great job explaining a very, very complex software system. A lot of the Zope specific details were left out as this was a book on Grok, but when the detail was required, it was very simple to digest and understand. I'll cover it chapter by chapter below, but the
Key Concepts Behind Grok and
Grok and the ZODB chapters were very informative. Not only did they help me digest what Grok is all about, they really underscored why some of the additional complexity is beneficial. See bullet points two and three above; I think the book worked.
I enjoyed the deployment chapter as well. That's more of my forte as I really build the systems that people use to build the systems (make sense? I work for a service provider). I'm not certain now NFS friendly ZODB is, but assuming they play well together, Grok ought to deploy alright via a FastCGI methodology on most shared hosts. Thank you, WSGI. Disclaimer time: I didn't try this and I worry slightly about multiple processes. Maybe that's a nice future post.
The Negatives
Not many. First, I did notice a few sections where the code didn't wrap so cleanly on the page. In one place, copying verbatim would have resulted in a SyntaxError. There were also some indention oddities, which were probably a means to avoid listing code errors. Not a big deal. The content was stellar.
Secondly, it really didn't cover non-Linux deployments. I'll never deploy it on Windows, AIX, an DGUX, or a hair dryer, but I can understand how a developer on one of these other systems may be disappointed in having to track down instructions somewhere on the Internet.
Chapter-by-Chapter
Here's a brief take on each of the chapters in the book. As I said above, a few of them really shine.
Chapter 1: Getting to Know Grok
Provides a quality overview of the Grok framework. Also clears up something that I'm fairly sure bothers a few developers right up front - it is possible to access a relational database system via a Zope-based framework! There are also touches on how the framework differs from others, which is to be expected.
Chapter 2: Getting Started with Grok
A general run down of how to install Grok, the directory structure, and what you'll find on the inside. Note that this covers virtualenv, which is a huge plus. Mucking with a system Python install, in my opinion, is evil.
Chapter 3: Views
You'll learn TAL, that's for certain. Having never worked with TAL, I kind of like it's approach.
Chapter 4: Models
This chapter begins to really introduce ZODB, and it does a very good job. Containers, models, persistence. It's covered at a high Grok-level detail.
Chapter 5: Forms
Quite honestly, I had trouble following this one a bit. It's simply an interest problem. Being that I generally don't spend a whole lot of time dealing with web based applications and form configurations, this just wasn't relevant to what I do on a daily basis.
Chapter 6: An Object-Oriented Search Engine
Ah-ha! So that's how one manages to query a ZODB instance without "CREATE INDEX..." support! Carlos does a great job of making the catalog concept very clear as well as separating it from the other "noise" and terminology that surrounds a Zope application. The big take-away here? Catalogs == Good. They're akin to providing good indexing on your relational tables.
Chapter 7: Security
As it turns out, security is rather complex in a Zope application. Surprised? Again, a wonderful job of taking a topic that is hard to swallow and making it clear. Principals, roles, users, groups. pluggable architecture, interfaces, and more. All of this to just sign in? Yup. But that's okay, by the end of "#7", you'll understand how it all works.
Chapter 8: Application Presentation and Page Layout
This falls into the same category as chapter 5 does. Informative, well written, good coverage, just not something I'm very involved in. This chapter clears up how one segments views via TAL templates (think {% block %} or a Mako 'def' statement).
Chapter 9: Grok and the ZODB
Well, by about this time I really started to get excited about the ZODB system and what it can do. Why should I have to care about joins, tables, ORMs, Unit-of-Work vs Active Record, thinking "flat" versus "object", or correct escapes to avoid injection attacks? By about halfway through this chapter I had started to scheme up ways to start looking at ZODB for my own purposes.
Chapter 10: Grok and Relational Database
An introduction to SQLAlchemy and an implementation of authentication using a relational database. Solid information, especially if your concerned with integrating with existing data stores.
Chapter 11: Key Concepts Behind Grok
This was my favorite chapter. Grok aside, all of those Zope bells and whistles start to really shine here. Interfaces? What about duck-typing? Oh! I see. Adapters? Why formalize something like.. oh? A registry? Hey that saves me time! By the end of this chapter, it's apparent that there is quite a bit of value in the ZCA and it's worth investigating.
Chapter 12: Grokkers, Martian, and Agile Configuration
I'm going to be honest here. I largely skimmed this.
Chapter 13: Testing and Debugging
Provides an detailed rundown of the testing methodologies and utilities available when developing a Grok application.
Chapter 14: Deployment
I'm already rather familiar with WSGI and standard deployment techniques, but this gives a nice rundown for those that are not. The ZEO configuration parts did provide some new information, though.
To sum it all up...
A good resource to have if you intend to do anything with Grok. Additionally, it does a good job of describing some of the core Zope components from a Grok point of view. I can easily see myself grabbing this book when I want to refresh my Zope memory before I head over to the Zope site. Also,
chapter 5 is available for free, so you can check it out before you
buy it.