- Timestamp:
- 20 Nov 2014, 03:06:02 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/zcml.py
r11993 r11999 16 16 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 17 ## 18 import os 18 19 from zope.component.zcml import handler 20 from zope.configuration.exceptions import ConfigurationError 19 21 from waeup.ikoba.interfaces import IDataCenterConfig, IPayPalConfig 20 22 … … 52 54 53 55 56 def paypal_handler(path): 57 """ZCML handler that registers paypal configuration. 58 59 We expect paypal credentials written down in a config file. The 60 path to this config file can be set with the ZCML `paypalconf` 61 directive, which is handled here. 62 63 This handler requires the given path to exist and to be a file. 64 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 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. 73 """ 74 if not os.path.exists(path): 75 raise ConfigurationError("No such file: %s" % path) 76 if not os.path.isfile(path): 77 raise ConfigurationError("Not a regular file: %s" % path) 78 return handler( 79 'registerUtility', {'path': path}, IPayPalConfig, '') 80 81 54 82 def paypal_conf(context, path): 55 83 """Handler for ZCML paypalconf directive. 84 85 This handler registers the `paypal_handler` above to perform the 86 real configuration action. 56 87 """ 57 88 context.action( 58 89 discriminator=('utility', IPayPalConfig, ''), 59 callable=handler, 60 args=( 61 'registerUtility', 62 {'path': path}, IPayPalConfig, '') 90 callable=paypal_handler, 91 args=(path, ) 63 92 )
Note: See TracChangeset for help on using the changeset viewer.