Index: in/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/tests/sample-paypalconf.zcml
===================================================================
--- /main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/tests/sample-paypalconf.zcml	(revision 11998)
+++ 	(revision )
@@ -1,13 +1,0 @@
-<configure
-   xmlns="http://namespaces.zope.org/zope"
-   xmlns:ikoba="http://namespaces.waeup.org/ikoba"
-   i18n_domain="waeup.ikoba"
-   package="waeup.ikoba.tests"
-   >
-  <include package="waeup.ikoba" file="meta.zcml" />
-
-  <!-- Sample for the 'paypalconf' directive: -->
-  <ikoba:paypalconf
-      path="/path/to/some/paypal.conf" />
-
-</configure>
Index: /main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/tests/test_zcml.py
===================================================================
--- /main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/tests/test_zcml.py	(revision 11998)
+++ /main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/tests/test_zcml.py	(revision 11999)
@@ -1,2 +1,3 @@
+import os
 import tempfile
 import shutil
@@ -51,4 +52,11 @@
             gsm.unregisterUtility(conf, iface)
 
+    def create_fake_paypal_configs(self):
+        # create two regular files in workdir
+        self.conf1_path = os.path.join(self.workdir, 'paypal1.conf')
+        self.conf2_path = os.path.join(self.workdir, 'paypal2.conf')
+        open(self.conf1_path, 'w').write('Fake')
+        open(self.conf2_path, 'w').write('Fake')
+
     def test_datacenter_config_directive(self):
         # the 'datacenter' directive can be used in ZCML
@@ -71,15 +79,37 @@
         # the 'paypalconf' ZCML directive works
         assert queryUtility(IPayPalConfig) is None
-        zcfile("sample-paypalconf.zcml", tests)  # 'execute' the ZCML file
+        self.create_fake_paypal_configs()
+        config = get_zcml_conf(
+            '<ikoba:paypalconf path="%s" />' % self.conf1_path
+            )
+        zcstring(config)  # execute ZCML
         result = getUtility(IPayPalConfig)
-        assert result == {'path': u'/path/to/some/paypal.conf'}
+        assert result == {'path': self.conf1_path}
 
     def test_paypal_config_singleton(self):
         # we can define only one paypal config
+        assert queryUtility(IPayPalConfig) is None
+        self.create_fake_paypal_configs()
         config = get_zcml_conf(
-            '<ikoba:paypalconf path="/some/path" />'
-            '<ikoba:paypalconf path="/other/path" />'
-            )
+            '<ikoba:paypalconf path="%s" />'
+            '<ikoba:paypalconf path="%s" />'
+            ) % (self.conf1_path, self.conf2_path)
         assert queryUtility(IPayPalConfig) is None
         self.assertRaises(
             ConfigurationError, zcstring, config)
+
+    def test_paypal_config_no_such_file(self):
+        # a set paypal config file must exist
+        config = get_zcml_conf(
+            '<ikoba:paypalconf path="/not/eXiStInG/path" />')
+        self.assertRaises(
+            ConfigurationError, zcstring, config)
+
+    def test_paypal_config_not_a_regular_file(self):
+        # a paypal config file must be a regular file
+        dirpath = os.path.join(self.workdir, 'mydir')
+        os.mkdir(dirpath)
+        config = get_zcml_conf(
+            '<ikoba:paypalconf path="%s" />' % dirpath)
+        self.assertRaises(
+            ConfigurationError, zcstring, config)
Index: /main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/zcml.py
===================================================================
--- /main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/zcml.py	(revision 11998)
+++ /main/waeup.ikoba/branches/uli-payments/src/waeup/ikoba/zcml.py	(revision 11999)
@@ -16,5 +16,7 @@
 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 ##
+import os
 from zope.component.zcml import handler
+from zope.configuration.exceptions import ConfigurationError
 from waeup.ikoba.interfaces import IDataCenterConfig, IPayPalConfig
 
@@ -52,12 +54,39 @@
 
 
+def paypal_handler(path):
+    """ZCML handler that registers paypal configuration.
+
+    We expect paypal credentials written down in a config file. The
+    path to this config file can be set with the ZCML `paypalconf`
+    directive, which is handled here.
+
+    This handler requires the given path to exist and to be a file.
+
+    If the file exists and is readable, a dict with ``path`` set to
+    the given path is registered as a global unnamed utility for the
+    `IPayPalConfig` interface.
+
+    We do not check more (syntax, etc. of a found config) as this is
+    beyond the scope of ZCML configuration. ZCML is responsible for
+    finding _some_ paypal configuration file, not for the values found
+    (or not found) within this file.
+    """
+    if not os.path.exists(path):
+        raise ConfigurationError("No such file: %s" % path)
+    if not os.path.isfile(path):
+        raise ConfigurationError("Not a regular file: %s" % path)
+    return handler(
+        'registerUtility', {'path': path}, IPayPalConfig, '')
+
+
 def paypal_conf(context, path):
     """Handler for ZCML paypalconf directive.
+
+    This handler registers the `paypal_handler` above to perform the
+    real configuration action.
     """
     context.action(
         discriminator=('utility', IPayPalConfig, ''),
-        callable=handler,
-        args=(
-            'registerUtility',
-            {'path': path}, IPayPalConfig, '')
+        callable=paypal_handler,
+        args=(path, )
         )
