Book Details

ISBN 139781847197481

Paperback308 pages

Book Description

Python is a very popular language for web application development. It's easy to learn and powerful enough to program any kind of system. There are many options for Python web development frameworks, from lightweight packages to everything-and-the-kitchen sink solutions. However, Grok offers a solid foundation for developing powerful, extensible, and secure web applications without too much complexity. This is because it is based on a very advanced object-oriented web framework: Zope 3. Grok enables web developers to tap into the power of Zope 3, thus giving a range of useful features for our applications with very little code.

This book offers Python developers a comprehensive understanding of Grok and a look at its main features by way of developing and evolving a sample application from concept to deployment. You will learn how to use Grok to create web applications and how Grok offers you an agile and enjoyable development experience.

This book will introduce you to the Grok web development framework and show you how to create an application from start to finish. You will learn how to create an application using mostly page templates and then add features to it while reworking the code as it grows. You will learn how to use models to describe your application's domain and how to connect those models to views for presenting information to your users. You will also learn how to automatically generate forms from the models and how to store the data and make it searchable. Due to the public nature of the Web, security is an important part of any web application and you will learn how Grok's integrated security can be used to protect your application and grant access to specific users and roles when needed. Grok offers a powerful object database for storage, but can also interact nicely with any database directly or using an object-relational mapper. You will learn how to do both and when it's advisable to use each. You will also learn how to extend a third-party Grok application, how to debug it, and how to deploy it. By the end of the book, you will be able to design and develop a complete web application using Grok.

Table of Contents

Chapter 1: Getting to Know Grok

Why Grok?

Distinguishing Grok concepts

Other Grok features

How Grok compares to other web frameworks

Summary

Chapter 2: Getting Started with Grok

Getting a C compiler

Installing Python

EasyInstall and the Python Package Index (PyPI)

Grok and the Python environment

Virtualenv

What's inside a Grok project?

The Grok admin UI

Summary

Chapter 3: Views

Grok views

Zope Page Templates (ZPT)

The to-do list application

Handling form data

Adding static resources

Putting in some JavaScript flourish

Summary

Chapter 4: Models

Models and applications

Storing model data

Display logic and application logic

Using containers and multiple models

The Grok introspector

Summary

Chapter 5: Forms

A quick demonstration of automatic forms

Interfaces

Schemas

Summary

Chapter 6: The Catalog: An Object-Oriented Search Engine

Catalogs and indexes

Adding a simple search function to the application

A brief diversion: Structuring our application for search

Back to search: Using multiple indexes

Indexing different kinds of objects

The catalog admin UI

Types of indexes

Summary

Chapter 7: Security

Authentication and authorization

Principals, permissions, and roles

Security policies

Setting up a custom security policy

Adding authentication

Summary

Chapter 8: Application Presentation and Page Layout

Viewlets and viewlet managers

Understanding how the pieces fit together

To-do list manager layout

Layers and skins

Adding themes to our application

Summary

Chapter 9: Grok and the ZODB

How the ZODB works

Using the ZODB

Adding Blob support to our application

Taking advantage of transactions

ZODB maintenance

Summary

Chapter 10: Grok and Relational Databases

Object Relational Mappers

Using a relational database for authentication

Handling database transactions securely

Creating database-backed models and containers

When to use the ZODB versus a relational database

Summary

Chapter 11: Key Concepts Behind Grok

The Zope Component Architecture

Extending a Grok application from the outside

Summary

Chapter 12: Grokkers, Martian, and Agile Configuration

Agile configuration

The Martian library

Understanding grokkers

Creating our own grokker for zope.sendmail configuration

Summary

Chapter 13: Testing and Debugging

Testing

Testing in Grok

Debugging

Summary

Chapter 14: Deployment

Moving an application to production mode

Running the paster server in the background

Running Grok behind the Apache web server

More scalability: Adding caching and load balancing

Summary

What You Will Learn

Basic concepts of the Zope Component Architecture

Use Zope Page Templates to produce HTML pages

Design efficient applications using models and views

Use Grok's automatic form generation mechanisms

Add selectable themes or skins to your applications

Index content from the models you defined and learn how to search this content by querying the catalog, including full text search

Understand how the Zope Object Database works and how simple and useful it is

Easily connect to other relational databases using SQLAlchemy

Create extensions to your applications

Understand the various options to deploy your Grok application, and use buildout—a Python-based build system for deploying applications—to create a repeatable deployment

Authors

Carlos de la Guardia

Carlos has been doing web consulting and development since 1994, when selling any kind of project required two meetings just to explain what the Internet was in the first place. He was the co-founder of Aldea Systems, a web consulting company where he spent ten years working in all kinds of web projects using a diverse range of languages and tools. In 2005 he became an independent developer and consultant, specializing in Zope and Plone projects. He frequently blogs about Plone and other Zope-related subjects.

Alerts & Offers

Series & Level

We understand your time is important. Uniquely amongst the major publishers, we seek to develop and publish the broadest range of learning and information products on each technology. Every Packt product delivers a specific learning pathway, broadly defined by the Series type. This structured approach enables you to select the pathway which best suits your knowledge level, learning style and task objectives.

Learning

As a new user, these step-by-step tutorial guides will give you all the practical skills necessary to become competent and efficient.

Beginner's Guide

Friendly, informal tutorials that provide a practical introduction using examples, activities, and challenges.

Essentials

Fast paced, concentrated introductions showing the quickest way to put the tool to work in the real world.

Cookbook

A collection of practical self-contained recipes that all users of the technology will find useful for building more powerful and reliable systems.

Blueprints

Guides you through the most common types of project you'll encounter, giving you end-to-end guidance on how to build your specific solution quickly and reliably.

Mastering

Take your skills to the next level with advanced tutorials that will give you confidence to master the tool's most powerful features.

Starting

Accessible to readers adopting the topic, these titles get you into the tool or technology so that you can become an effective user.

Progressing

Building on core skills you already have, these titles share solutions and expertise so you become a highly productive power user.