It is customary for any tutorial to contain an obligatory section about how to install the products being documented.  Books about tech products likewise follow the same recipe.  Rather than duplicate perfectly good material found elsewhere, we shall instead highlight here some of the things which are less obvious to newcomers.

Rather excellent details on how to go about installing Grok may be found on the getting started page on the main Grok web site.

_________________________________________________________________________________________

It all boils down to:

$ easy_install grokproject
$ grokproject mygrok

Note: at this time, grokproject is broken due to some changes to setuptools.  It is still possible to use grokproject, by installing the latest zc.buildout package globally, and then manually running buildout after the automatic run fails.  See below.

grokproject currently fails with the error:
    "Couldn't find index page for zc.buildout (maybe misspelled?)"

At this point, type:

$ cd <the name of the folder grokproject just created, eg "mygrok">
$ pip install zc.buildout
$ buildout

This will complete the installation process.

________________________________________________________________________________

This will build a directory structure containing a working web server framework and a sample application in mygrok/src/mygrok/app.py.

Assuming you used mygrok as the name of your grok project, some of the details are not necessarily intuitive to a first time user.  The following comments and hints should prevent quite a bit of frustration for newcomers;

  • setup.py contains the configuration for your Grok installation, including any package dependencies
  • buildout.cfg contains additional information about versions of packages and buildout recipes which should be installed
  • running bin/buildout is necessary after changing either of the above files
  • bin/paster serve --reload parts/etc/deploy.ini will start up a server on port 8080 in production mode
  • bin/paster serve --reload parts/etc/debug.ini will start up a server on port 8080 in development mode
  • connecting to localhost on port 8080 brings up a management interface, where you can add applications to your server
  • Grok finds applications by scanning the directory structure for Python classes which derive from grok.Application.
  • It is best to create your own applications in their own Python package directories; IOW, directories containing __init__.py
  • View templates (or page templates) are located in a directory called <modulename>_templates in the same directory as your module.  For example, with app.py, the templates are located in app_templates.
  • It is best to include "zope.app.schema" in your setup.py immediately when starting out.  There is an outstanding problem whereby global utilities (grok.GlobalUtility) don't register themselves unless this is done.
  • Your setup.py includes a section for fanstatic:
    entry_points={
              'fanstatic.libraries': [
                  'mygrok = mygrok.resource:library',
    ...
    ] }
    which should be modified for each package directory from where you want to include static resources. There is more documentation on the Grok site about how to use fanstatic, but its a little hard to find.  Also look at the grokproject documentation, and at fanstatics home page.
  • buildout.cfg has a include-site-packages = false setting which may be set true if you want your local Grok instance to access site-wide packages.
  • The easiest way to set up your IDE is to set the interpreter to ~/mygrok/bin/python_console. This ensures that all of the buildout eggs are available to your IDE so that syntax highlighting and introspection works properly.

 

Grok 4 Noobs

The Compulsory Part about Installing Grok