Official Grok Documentation version 1.5


Grok uses a few decorators to register functions or methods for specific functionality.

grok.subscribe() – register a function as a subscriber for an event


Declare that the decorated function subscribes to an event or a combination of objects and events.

Applicable on module-level for functions. Requires at least one class or interface as argument.

grok.action() – declare a form submit handler

action(label, **options)

Decorator that defines an action factory based on a form method. The method receives the form data as keyword parameters.

grok.require() – protect a method with a permission


The decorated method will be protected by the permission. Used in web service views such as REST or XML-RPC.

grok.adapter/grok.implementer() – declare an adapter factory

These decorators are always used in tandem to declare an adapter factory.


Describes that a function adapts an object or a combination of objects.


Describes that a function that’s used as an adapter implements an interface or a number of interfaces.

Example 1: Adapt to an interface

def home_for_cave(cave):
    return Home()

Example 2: Adapt a regular class instead of an interface

def home_for_cave(cave):
    return Home()

Example 3: Declare a multi-adapter factory

@grok.adapter(ICave, IFire)
def cozy_dwelling(cave, fire):
    return Dwelling()