Free Sample
+ Collection

Grok 1.0 Web Development

Carlos de la Guardia

Create flexible, agile web applications using the power of Grok—a Python web framework
RRP $23.99
RRP $39.99
Print + eBook

Want this title & more?

$12.99 p/month

Subscribe to PacktLib

Enjoy full and instant access to over 2000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

Book Details

ISBN 139781847197481
Paperback308 pages

About This Book

  • Develop efficient and powerful web applications and web sites from start to finish using Grok, which is based on Zope 3
  • Integrate your applications or web sites with relational databases easily
  • Extend your applications using the power of the Zope Toolkit
  • Easy-to-follow and packed with practical, working code with clear explanations

Who This Book Is For

This book is intended for Python developers who want to create web applications but have little or no experience in web development. If you have used other web frameworks but are looking for one that enables you to create more complex applications without losing agility, you will also benefit from this book.

The reader is expected to have some basic Python knowledge and at least a general idea of how a web application works.

Table of Contents

Chapter 1: Getting to Know Grok
Why Grok?
Distinguishing Grok concepts
Other Grok features
How Grok compares to other web frameworks
Chapter 2: Getting Started with Grok
Getting a C compiler
Installing Python
EasyInstall and the Python Package Index (PyPI)
Grok and the Python environment
What's inside a Grok project?
The Grok admin UI
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
Chapter 4: Models
Models and applications
Storing model data
Display logic and application logic
Using containers and multiple models
The Grok introspector
Chapter 5: Forms
A quick demonstration of automatic forms
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
Chapter 7: Security
Authentication and authorization
Principals, permissions, and roles
Security policies
Setting up a custom security policy
Adding authentication
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
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
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
Chapter 11: Key Concepts Behind Grok
The Zope Component Architecture
Extending a Grok application from the outside
Chapter 12: Grokkers, Martian, and Agile Configuration
Agile configuration
The Martian library
Understanding grokkers
Creating our own grokker for zope.sendmail configuration
Chapter 13: Testing and Debugging
Testing in Grok
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

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

In Detail

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.


Read More