Changeset 12030


Ignore:
Timestamp:
21 Nov 2014, 13:09:24 (10 years ago)
Author:
uli
Message:

Activate PayPal? SDK on instance startup.

Location:
main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/tests/test_zcml.py

    r11999 r12030  
    5656        self.conf1_path = os.path.join(self.workdir, 'paypal1.conf')
    5757        self.conf2_path = os.path.join(self.workdir, 'paypal2.conf')
    58         open(self.conf1_path, 'w').write('Fake')
    59         open(self.conf2_path, 'w').write('Fake')
     58        open(self.conf1_path, 'w').write('[rest-client]\n')
     59        open(self.conf2_path, 'w').write('[rest-client]\n')
    6060
    6161    def test_datacenter_config_directive(self):
     
    8585        zcstring(config)  # execute ZCML
    8686        result = getUtility(IPayPalConfig)
    87         assert result == {'path': self.conf1_path}
     87        assert result == {
     88            'path': self.conf1_path,
     89            'client_id': None,
     90            'client_secret': None,
     91            'mode': 'sandbox'
     92            }
    8893
    8994    def test_paypal_config_singleton(self):
  • main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/zcml.py

    r11999 r12030  
    2020from zope.configuration.exceptions import ConfigurationError
    2121from waeup.ikoba.interfaces import IDataCenterConfig, IPayPalConfig
     22from waeup.ikoba.payments.paypal import configure_sdk
    2223
    2324
     
    5960    We expect paypal credentials written down in a config file. The
    6061    path to this config file can be set with the ZCML `paypalconf`
    61     directive, which is handled here.
     62    directive, which is handled here and looks like this::
     63
     64      <ikoba:paypalconf path='/some/path/to/paypal.conf' />
    6265
    6366    This handler requires the given path to exist and to be a file.
    6467
    65     If the file exists and is readable, a dict with ``path`` set to
    66     the given path is registered as a global unnamed utility for the
    67     `IPayPalConfig` interface.
     68    If the file exists and is readable, a dict with ``path`` and other
     69    values read from the configuration file is registered as a global
     70    unnamed utility for the `IPayPalConfig` interface.
    6871
    69     We do not check more (syntax, etc. of a found config) as this is
    70     beyond the scope of ZCML configuration. ZCML is responsible for
    71     finding _some_ paypal configuration file, not for the values found
    72     (or not found) within this file.
     72    See :func:`waeup.ikoba.payments.paypal.configure_sdk for details
     73    of the set dict.
    7374    """
    7475    if not os.path.exists(path):
     
    7677    if not os.path.isfile(path):
    7778        raise ConfigurationError("Not a regular file: %s" % path)
     79    config_dict = configure_sdk(path)
    7880    return handler(
    79         'registerUtility', {'path': path}, IPayPalConfig, '')
     81        'registerUtility', config_dict, IPayPalConfig, '')
    8082
    8183
Note: See TracChangeset for help on using the changeset viewer.