All pastes #208116 Raw Edit

wosc

public text v1 · immutable
#208116 ·published 2006-10-18 12:37 UTC
rendered paste body
"""
Global utilities can be created by subclassing grok.Utility:

  >>> IClub.providedBy(NormalClub())
  True

  >>> grok.grok(__name__)
  >>> from zope import component

  >>> normal_club = component.getUtility(IClub)
  >>> IClub.providedBy(normal_club)
  True
  >>> isinstance(NormalClub, normal_club)
  True

Named utilities are registered using grok.name:

  >>> huge_club = component.getUtility(IClub)
  >>> IClub.providedBy(huge_club)
  True
  >>> isinstance(HugeClub, huge_club)
  True
"""
import grok

from zope import interface

class IClub(interface.Interface):
    pass

class NormalClub(grok.Utility):
    grok.implements(IClub)

class HugeClub(grok.Utility):
    grok.implements(IClub)
    grok.name('huge')