Grok-like configuration for Zope local site and utilities
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


This package provides support to write local site and utilities for
Zope directly in Python (without ZCML).

.. contents::

Setting up ````

This package is essentially set up like the `grokcore.component`_
package, please refer to its documentation for details.  The only
additional ZCML line you will need is::

  <include package="" />

Put this somewhere near the top of your root ZCML file but below the
line where you include ``grokcore.component``'s configuration.


Global utilities are already managed by `grokcore.component`_.

Here a simple example of a local utility::

  from zope.interface import implements, Interface

  class IKangaroo(Interface):

      def jump():
         """Make all kangaroos jump somewhere.

  class KangarooUtility(

      def jump(self):

Now, we can register our utility to a local site. That will create
automatically, and register that utility when we create that site::

   class Jungle(, IKangaroo)

If you don't add the last line, you will still have your site, but
nothing to make jump your kangaroo. Then, you will be able to add
manually by hand after (if you want).

API Overview

Base classes

   Base class for your site.

   Base class for a ZODB-persitent local utility.


``local_utility(factory, provides=None, name=u'', setup=None, public=False, name_in_container=None``)
   Directive used on a site to register a local utility at the
   creation time:

      Would be the component to register (required parameter),

      Would be the interface used to query the local utility (required

      Would be the name used to query the local utility,

      Would be a function taking parameter. If defined it will be
      called after the utility is created with it as first and unique

      If true, the utility will be created in the site container
      itself, not in the site manager, and public will be able to
      access it directly.

      Would be used as id for the utility in container itwill be
      created. If not defined it will ask NameChooser to pick a name
      for it.

In addition, the ```` package exposes the
`grokcore.component`_ API.

.. _grokcore.component: