Grok 1.0 Web Development

Carlos de la Guardia

eBook: $23.99
Formats: PDF, PacktLib, ePub and Mobi formats
$20.39 save 15%!
Print book: $39.99
$35.99 save 10%!
Print + eBook bundle: $63.98
Includes free access to the book on PacktLib
$39.59 save 38%!
Free Shipping! UK, US, Europe and selected countries in Asia.
This book can also be purchased from:
Overview
Table of Contents
The Author
Reviews
Downloads
  • 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

Book Details

Language : English
Paperback : 308 pages [ 235mm x 191mm ]
Release Date : February 2010
ISBN : 1847197485
ISBN 13 : 978-1-847197-48-1
Author(s) : Carlos de la Guardia
Topics and Technologies : All Books, Open Source, Python, Web Development


Table of Contents

Preface
Chapter 1: Getting to Know Grok
Chapter 2: Getting Started with Grok
Chapter 3: Views
Chapter 4: Models
Chapter 5: Forms
Chapter 6: The Catalog: An Object-Oriented Search Engine
Chapter 7: Security
Chapter 8: Application Presentation and Page Layout
Chapter 9: Grok and the ZODB
Chapter 10: Grok and Relational Databases
Chapter 11: Key Concepts Behind Grok
Chapter 12: Grokkers, Martian, and Agile Configuration
Chapter 13: Testing and Debugging
Chapter 14: Deployment
Index
  • Chapter 1: Getting to Know Grok
    • Why Grok?
    • Distinguishing Grok concepts
      • The Zope Component Architecture
      • Object database
      • Object publishing and traversal
    • Other Grok features
      • Integrated security model
      • Easy use of existing Python libraries and modules
      • Static resources
      • Relational database access
      • Python Web Server Gateway Interface compatibility
    • How Grok compares to other web frameworks
      • PHP
      • Java frameworks
      • Ruby on Rails
      • Django
      • Pylons
    • Summary
  • Chapter 2: Getting Started with Grok
    • Getting a C compiler
    • Installing Python
      • Installing Python on Unix/Linux
      • Installing Python on Mac OS X
      • Installing Python on Windows
    • EasyInstall and the Python Package Index (PyPI)
    • Grok and the Python environment
    • Virtualenv
      • Installing Grok using grokproject
      • Creating our first project
      • Running the default application
    • What's inside a Grok project?
      • Overview of the application structure
      • Creating our first template
    • The Grok admin UI
      • Applications
      • Server control
      • Documentation
    • Summary
  • Chapter 3: Views
    • Grok views
    • Zope Page Templates (ZPT)
      • The Template Attribute Language (TAL)
      • Expression types
      • Inserting text
      • Repeating tags
      • Conditional elements
      • Variables
      • Special variables
      • Modifying HTML tag attributes
      • Inserting structure
      • Multiple statements in one tag
      • Macros and slots
      • Going beyond ZPT basics
    • 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
      • The ZODB
      • Changing the title dynamically
      • The rules of persistence
    • Display logic and application logic
      • Separating display and application logic
    • Using containers and multiple models
      • Adding containers to our application
      • Adding behavior to the models
      • The TodoList model
      • Reorganizing the views
      • Introducing class annotations
      • Setting view names explicitly
      • Redirecting views
    • The Grok introspector
    • Summary
  • Chapter 5: Forms
    • A quick demonstration of automatic forms
    • Interfaces
      • Example of an interface
      • Interfaces in Grok
    • Schemas
      • Available schema attributes and field types
    • Form fields and widgets
    • Form components
      • Adding a project container at the root of the site
      • Form actions
      • Trying out the application
    • Filtering fields
    • Using grok.EditForm
    • Modifying individual form fields
    • Form validation
    • Customizing the form template
    • Summary
  • Chapter 6: The Catalog: An Object-Oriented Search Engine
    • Catalogs and indexes
    • Adding a simple search function to the application
      • Defining a simple index
      • Creating the search view
      • Creating a template to display the search results
    • 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
      • Default Grok security policy definition
      • Modifying the security policy
        • Modifying the default view permissions
        • Adding a new user
        • Protecting a view
    • Setting up a custom security policy
      • Creating permissions
      • Roles
    • Adding authentication
      • The Pluggable Authentication Utility
      • Registering PAU with our application
      • Adding a credentials plugin
        • The login form
        • The logout view
      • The UserAuthenticator plugin
        • Adding users
        • Basic user management
    • Summary
  • Chapter 8: Application Presentation and Page Layout
    • Viewlets and viewlet managers
      • Viewlets
      • Viewlet managers
    • Understanding how the pieces fit together
      • View methods and attributes
      • Viewlet methods and attributes
      • Viewlet manager methods and attributes
    • To-do list manager layout
      • Defining viewlet managers in application code
      • Registering viewlets
      • Modifying existing views to use the master template
      • Inserting forms into viewlets
      • Using viewlets to insert different static resources
    • Layers and skins
      • Skins in Grok
    • Adding themes to our application
      • Overriding a viewlet
      • Using the new skins
    • Summary
  • Chapter 9: Grok and the ZODB
    • How the ZODB works
      • Transparency
      • ACID properties
      • Other ZODB features
      • ZEO
    • Using the ZODB
      • The rules of persistence
      • Traversal
      • How Grok uses the ZODB
    • Adding Blob support to our application
      • Adding messages to projects
        • The megrok.form package
        • Adding an external package to our project
        • How blob support is configured in Grok
        • The messaging class and schema
        • The message viewlet
        • The message list template
        • Downloading an attachment
        • Testing the Blob support
    • Taking advantage of transactions
      • Using zope.app.undo
      • Testing the undo functionality
    • ZODB maintenance
      • File storage
      • Automatic packing
      • Backing up
      • Using the ZODB without Grok
    • Summary
  • Chapter 10: Grok and Relational Databases
    • Object Relational Mappers
      • SQLAlchemy
      • Including SQLAlchemy in our Grok project
        • Using SQLAlchemy
    • Using a relational database for authentication
    • Handling database transactions securely
    • Creating database-backed models and containers
      • The megrok.rdb package
      • Making an application database backed
    • When to use the ZODB versus a relational database
    • Summary
  • Chapter 11: Key Concepts Behind Grok
    • The Zope Component Architecture
      • Interfaces
      • Adapters
        • Real-world adapters
        • Defining and using an adapter
        • Adapters that we have used in our application
      • Utilities
        • Global utilities
        • Local utilities
      • Events
    • Extending a Grok application from the outside
      • Preparing the original application
      • The to-do plus package
        • Creating the new package
      • Adding a skin chooser form to the application
        • Adding a new skin
        • The skin chooser form
        • Using events to show the selected skin
      • Sending e-mail notifications on content creation
        • Object annotations
        • Creating the form
        • Sending the e-mail
      • Displaying additional navigation links
    • Summary
  • Chapter 12: Grokkers, Martian, and Agile Configuration
    • Agile configuration
    • The Martian library
    • Understanding grokkers
      • The grokked class
      • The directives
      • The class grokker
      • The only ZCML you'll ever need
    • Creating our own grokker for zope.sendmail configuration
      • Creating the package
      • Writing our grokker
      • Using mailgrokker
    • Summary
  • Chapter 13: Testing and Debugging
    • Testing
      • Unit testing
      • Functional tests
    • Testing in Grok
      • Doctests
      • Default test setup for Grok projects
        • Test configuration
        • Test files
        • Running the tests
      • The test runner
        • Test layers
        • Invoking the test runner
      • Looking at the test code
        • ftesting.zcml
        • tests.py
        • app.txt
      • Adding our own tests
        • The Browser class
        • Our first to-do application tests
        • Adding unit tests
        • Extending the test suite
    • Debugging
      • Debugging in Grok
        • The default Ajax debugger
        • Post-mortem debugging with the Python debugger
    • Summary
  • Chapter 14: Deployment
    • Moving an application to production mode
    • Running the paster server in the background
    • Running Grok behind the Apache web server
      • Using mod_rewrite to serve our application from Apache
      • Installing and setting up Grok under mod_wsgi
        • WSGI: The Python Web Server Gateway Interface
        • Grok and WSGI
        • Why use Apache and mod_wsgi for Grok?
        • Setting up a clean Linux server
        • Installing and configuring mod_wsgi
        • Configuring a Grok site under mod_wsgi
        • Getting the to-do application ready for mod_wsgi
        • Configuring an Apache site to use mod_wsgi
        • Running the application
      • Adding a ZEO server
        • Buildout recipe for the ZEO configuration
        • Configuring the ZEO client
        • Launching the ZEO server
        • Augmenting the number of processes
    • More scalability: Adding caching and load balancing
      • Caching proxies
      • Load balancers
      • A high-traffic architecture for Grok
    • Summary

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.

Sample chapters

You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

Find your book in our support section to find errata and to download code samples.

What you will learn from this book

  • 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

Special Offers

PacktLib gives you access to this and 600+ other titles with an annual or monthly subscription.

Annual subscription:

$220.00 per annum

Monthly subscription:

$21.99 per month

Buy 2 eBooks
and Get 50% Off
+
Buy Grok 1.0 Web Development with Python 2.6 Text Processing: Beginners Guide and get 50% off both the eBooks.
Just add both the eBooks to your shopping cart and enter dgro5pyeb in the 'Enter Promotion Code' field. Click 'Add Promotion Code' and the discount will be applied.
View Best Selling eBook offers

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.

A concise, practical guide for creating powerful web applications and web sites with ease

Approach

The book takes a practical approach and dives into code right from the start. After learning how to install Grok, we create a simple application. We work on this application throughout the book, until its deployment in the last chapter.

In each chapter, some new features of Grok will be introduced and explained, then the application will be extended to use them, explaining step-by-step how each feature works.

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.

Are there no books available that are right for you at the moment? How about signing up to our newsletter to keep up to date?
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Sort A-Z