source: main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/zcml.py @ 11993

Last change on this file since 11993 was 11993, checked in by uli, 10 years ago

pep8.

  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
1## $Id: zcml.py 11993 2014-11-19 15:36:52Z uli $
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.ikoba.interfaces import IDataCenterConfig, IPayPalConfig
20
21
22def data_center_conf(context, path):
23    """Handler for ZCML ``datacenter`` directive.
24
25    Registers a global utility under IDataCenterConfig and containing
26    a dictionary with (currently) only one entry: `path`.
27
28    The directive can be put into site.zcml like this:
29
30    - Add to the header:
31        ``xmlns:ikoba="http://namespaces.waeup.org/ikoba"``
32
33    - Then, after including waeup.ikoba:
34        ``<ikoba:datacenter path="some/existing/file/path" />``
35
36    In a running instance (where some directive like above was
37    processed during startup), one can then ask for the
38    IDataCenterConfig utility:
39
40      >>> from waeup.ikoba.interfaces import IDataCenterConfig
41      >>> from zope.component import getUtility
42      >>> getUtility(IDataCenterConfig)
43      {'path': 'some/existing/file/path'}
44
45    """
46    context.action(
47        discriminator=('utility', IDataCenterConfig, ''),
48        callable=handler,
49        args=('registerUtility',
50              {'path': path}, IDataCenterConfig, '')
51        )
52
53
54def paypal_conf(context, path):
55    """Handler for ZCML paypalconf directive.
56    """
57    context.action(
58        discriminator=('utility', IPayPalConfig, ''),
59        callable=handler,
60        args=(
61            'registerUtility',
62            {'path': path}, IPayPalConfig, '')
63        )
Note: See TracBrowser for help on using the repository browser.