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

Last change on this file since 14948 was 8057, checked in by Henrik Bettermann, 13 years ago

Adjust copyright header and propset svn:keywords.

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