\chapter{Functions}

The \module{grok} module provides a number of convenience functions to aid in
common tasks.

  \section{\function{grok.getSite}}

    \begin{funcdesc}{grok.getSite}{}
    Get the current site object.

      \begin{seealso}
      Site objects are instances of \class{grok.Site} and/or
      \class{grok.Application}.
      \end{seealso}

      \begin{seealso}
      \seetitle
      [http://worldcookery.com/WhereToBuy]
      {Web Component Development With Zope 3, second edition}
      {By Philiip von Weitershaussen; Chapter 18 describes the use of Site
      objects.}
      \end{seealso}

    \end{funcdesc}

  \section{\function{grok.notify}}

    \begin{funcdesc}{grok.notify}{event}
    Send \var{event} to event subscribers.

    Example:
\begin{verbatim}
import grok

class Mammoth(object):
    def __init__(self, name):
        self.name = name

manfred = Mammoth('manfred')

grok.notify(grok.ObjectCreatedEvent(manfred))
\end{verbatim}

      \begin{seealso}
      Grok events provide a selection of common event types.
      \end{seealso}

      \begin{seealso}
      \seetitle
      [http://worldcookery.com/WhereToBuy]
      {Web Component Development With Zope 3, second edition}
      {By Philiip von Weitershaussen; Chapter 16 describes the Zope 3 event
      system.}
      \end{seealso}

    \end{funcdesc}

  \section{\function{grok.url}}

    \begin{funcdesc}{grok.url}{request, object, \optional{, name}}
    Construct a URL for the given \var{request} and \var{object}.

    \var{name} may be a string that gets appended to the object URL. Commonly
    used to construct an URL to a particular view on the object.

    This function returns the constructed URL as a string.

      \begin{seealso}
      View classes derived from \class{grok.View} have a similar \method{url}
      method for constructing URLs.
      \end{seealso}
    \end{funcdesc}
