Index: /main/waeup.sirp/trunk/src/waeup/sirp/browser/captcha.py
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/browser/captcha.py	(revision 7283)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/browser/captcha.py	(revision 7284)
@@ -24,4 +24,5 @@
 import urllib2
 from zope import schema
+from zope.component import getUtilitiesFor
 from zope.interface import Interface
 from zope.publisher.interfaces.http import IHTTPRequest
@@ -91,4 +92,53 @@
     By default we require no configuration data.
     """
+
+class ICaptchaChooser(Interface):
+    """A chooser that collects available captchas.
+    """
+    def getAvailCaptchas(self):
+        """Return a dict of available captchas with registered names as keys.
+        """
+
+    def getCaptcha(self):
+        """Get captcha chosen for a certain site or default.
+        """
+
+    def getConfigData(self, captcha):
+        """Get a dict of config data for a certain captcha.
+        """
+
+    def setConfigData(self, captcha, key, value):
+        """Set a certain configuration key for a certain captcha.
+        """
+
+#
+# Global captcha chooser
+#
+from zope.publisher.browser import TestRequest
+class CaptchaChooser(grok.GlobalUtility):
+
+    grok.implements(ICaptchaChooser)
+
+    def getAvailCaptchas(self):
+        """Get all available captchas registered as utils for ICaptcha.
+
+        The default captcha (as it most probably is a copy of another
+        registered captcha) is left out of the result.
+
+        Result will be a dict with registration names as keys and the
+        specific captcha instances as values.
+        """
+        result = getUtilitiesFor(ICaptcha)
+        return dict([x for x in result
+                       if x != u''])
+
+    def getCaptcha(self):
+        site = grok.getSite()
+        name = ''
+        if site is None:
+            # return the default captcha, registered without name
+            return getUtility(ICaptcha)
+        name = site.get('configuration', None).get('captcha', u'')
+        return getUtility(ICaptcha, name=name)
 
 #
@@ -109,5 +159,5 @@
         return
 
-class NullCaptcha(grok.Adapter):
+class NullCaptcha(object):
     """A captcha that does not expect any input.
 
@@ -120,10 +170,6 @@
     maintainer decides not to use it at all.
     """
-    grok.context(IHTTPRequest)
     grok.implements(ICaptcha)
-    grok.name('No captcha')
-
-    def __init__(self, context=None):
-        self.context = None
+    #grok.name(u'No captcha')
 
     def verify(self, captcha_request):
@@ -133,4 +179,9 @@
         return u''
 
+
+# This captcha is registered twice: one time as a 'no captcha' captcha
+# and then also as the default captcha (with empty name)
+grok.global_utility(NullCaptcha, name=u'No captcha')
+grok.global_utility(NullCaptcha, name=u'')
 
 #
