Personal tools
You are here: Home Documentation Tutorials Grok Poller Tutorial

Grok Poller Tutorial

This Tutorial applies to: 1.0
This Tutorial is intended for: Developer

This tutorial shows how to implement a simple polling application using Grok.

All content on one page (useful for printing, presentation mode etc.)

  1. Introduction The core audience of this tutorial is programmers that already are already familiar with Python and Web development, but might not know anything about Zope.
  2. Poller Idea The poller application, that we will implement in this tutorial, is a simple Web application, which let's the users create polls with multiple voting options.
  3. Grok Setup Follow the Grok Tutorial instructions on installing Grok an setting up a project.
  4. Models Creating the application data model.
  5. The First View We will now implement the first view of the poller application; which will list all the polls for the users, and provide a link to add new polls.
  6. Zope Page Templates How to create display templates using the templating language TAL.
  7. Adding Objects To add polls, we want to provide a Web form for the users.
  8. Interfaces In the previous section, we defined a schema for the ``Poll`` class manually, which is not a good solution, as we might need multiple forms for them, and thus will need to repeat a lot of code.
  9. Naming Content In the `Adding Objects`_, we made a form that creates new polls and adds them to a container. But we overlooked a problem in the way that Grok object traversal works.
  10. Adapters This section tries to be a short introduction to adapters as they are used in Zope component architecture; thus Grok, and as an example, we will use the ``NameChooser`` mentioned in the previous section, and implement our own version of it.
  11. Implementing the Name Chooser We now have a simple name chooser adapter, but it doesn't really do anything useful, and it doesn't fix the problems we had with the URL's.
  12. Poll View Now it's time to implement a view for the poll items which allows the user to vote on options.
  13. Poll Results View Now all that is left for our simple poller application is the results view for the poll, which doesn't show us anything new, we just use the "string:" TALES expression just to show how it works.
  14. Conclusion In this tutorial you learned about multiple concepts regarding Grok Web application development, such as interfaces, schemas, adapters and page templates with models, containers, views and form generation.