source: main/waeup.kofa/trunk/src/waeup/kofa/zcml.py @ 7912

Last change on this file since 7912 was 7811, checked in by uli, 13 years ago

Rename all non-locales stuff from sirp to kofa.

File size: 1.9 KB
RevLine 
[7576]1##
2## zcml.py
3## Login : <uli@pu.smp.net>
4## Started on  Fri Feb  3 04:26:49 2012 Uli Fouquet
5## $Id$
6##
7## Copyright (C) 2012 Uli Fouquet
8## This program is free software; you can redistribute it and/or modify
9## it under the terms of the GNU General Public License as published by
10## the Free Software Foundation; either version 2 of the License, or
11## (at your option) any later version.
12##
13## This program is distributed in the hope that it will be useful,
14## but WITHOUT ANY WARRANTY; without even the implied warranty of
15## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16## GNU General Public License for more details.
17##
18## You should have received a copy of the GNU General Public License
19## along with this program; if not, write to the Free Software
20## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21##
22from zope.component.zcml import handler
[7811]23from waeup.kofa.interfaces import IDataCenterConfig
[7576]24
25def data_center_conf(context, path):
26    """Handler for ZCML ``datacenter`` directive.
27
28    Registers a global utility under IDataCenterConfig and containing
29    a dictionary with (currently) only one entry: `path`.
30
31    The directive can be put into site.zcml like this:
32
33    - Add to the header:
[7811]34        ``xmlns:kofa="http://namespaces.waeup.org/kofa"``
[7576]35
[7811]36    - Then, after including waeup.kofa:
37        ``<kofa:datacenter path="some/existing/file/path" />``
[7576]38
39    In a running instance (where some directive like above was
40    processed during startup), one can then ask for the
41    IDataCenterConfig utility:
42
[7811]43      >>> from waeup.kofa.interfaces import IDataCenterConfig
[7576]44      >>> from zope.component import getUtility
45      >>> getUtility(IDataCenterConfig)
46      {'path': 'some/existing/file/path'}
47
48    """
49    context.action(
50        discriminator = ('utility', IDataCenterConfig, ''),
51        callable = handler,
52        args = ('registerUtility',
53                {'path':path}, IDataCenterConfig, '')
54        )
Note: See TracBrowser for help on using the repository browser.