summaryrefslogtreecommitdiff
path: root/docs/zcml/utility.rst
blob: 1341dfb83e7c5655fa7b2535ff254482982ab741 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
.. _utility_directive:

``utility``
-----------

Register a :term:`Zope Component Architecture` "utility".

Attributes
~~~~~~~~~~

``component``
  The utility component (cannot be specified if ``factory`` is
  specified).

``factory``
  A factory that creates a component (cannot be specified if
  ``component`` is specified).

``provides``
  The :term:`interface` that an utility instance resulting from a
  lookup will provide.

``name``
  The utility name.

Example
~~~~~~~

.. code-block:: xml
   :linenos:

   <utility
     provides=".interfaces.IMyUtility"
     component=".utilities.MyUtility"
     />

Alternatives
~~~~~~~~~~~~

Use the ``registerUtility`` method of the ``registry`` attribute of a
:term:`Configurator` instance during initial application setup.

See Also
~~~~~~~~

None.