Index: /main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py	(revision 8041)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py	(revision 8042)
@@ -23,4 +23,5 @@
 from time import time
 from datetime import datetime, date
+from zope.event import notify
 from zope.component import getUtility, createObject, getAdapter
 from zope.catalog.interfaces import ICatalog
@@ -907,4 +908,6 @@
             self.applyData(applicant, **data)
             self.context.addApplicant(applicant)
+            applicant.reg_number = applicant.applicant_id
+            notify(grok.ObjectModifiedEvent(applicant))
         elif self.context.mode == 'update':
             # Update applicant
@@ -916,19 +919,26 @@
             if results:
                 applicant = results[0]
-                if applicant.password is not None:
-                    self.flash(_('Your password has already been set. '
-                                  'Please proceed to the login page.'))
-                    return
-                elif getattr(applicant,'firstname',None) is None:
+                if getattr(applicant,'firstname',None) is None:
                     self.flash(_('An error occurred.'))
                     return
                 elif applicant.firstname.lower() != firstname.lower():
+                    # Don't tell the truth here. Anonymous must not
+                    # know that a record was found and only the firstname
+                    # verification failed.
                     self.flash(_('No application record found.'))
                     return
+                elif applicant.password is not None:
+                    self.flash(_('Your password has already been set. '
+                                 'Please proceed to the login page.'))
+                    return
+                # Store email address but nothing else.
                 applicant.email = data['email']
+                notify(grok.ObjectModifiedEvent(applicant))
             else:
+                # No record found, this is the truth.
                 self.flash(_('No application record found.'))
                 return
         else:
+            # Does not happen but anyway ...
             return
         kofa_utils = getUtility(IKofaUtils)
Index: /main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py	(revision 8041)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py	(revision 8042)
@@ -26,4 +26,5 @@
 from mechanize import LinkNotFoundError
 from zope.event import notify
+from zope.catalog.interfaces import ICatalog
 from zope.component import createObject, getUtility
 from zope.component.hooks import setSite, clearSite
@@ -799,6 +800,6 @@
         self.browser.getLink("Register for application").click()
         # Fill the edit form with suitable values
-        self.browser.getControl(name="form.firstname").value = 'John'
-        self.browser.getControl(name="form.lastname").value = 'Tester'
+        self.browser.getControl(name="form.firstname").value = 'Anna'
+        self.browser.getControl(name="form.lastname").value = 'Kurios'
         self.browser.getControl(name="form.email").value = 'xx@yy.zz'
         self.browser.getControl(name="form.phone.country").value = ['+234']
@@ -808,4 +809,17 @@
         self.assertEqual(self.browser.url,
             self.container_path + '/registration_complete?email=xx%40yy.zz')
+        # The new applicant can be found in the catalog via the email address
+        cat = getUtility(ICatalog, name='applicants_catalog')
+        results = list(
+            cat.searchResults(email=('xx@yy.zz', 'xx@yy.zz')))
+        applicant = results[0]
+        self.assertEqual(applicant.lastname,'Kurios')
+        # The application_id has been copied to the reg_number
+        self.assertEqual(applicant.applicant_id, applicant.reg_number)
+        # The applicant can be found in the catalog via the reg_number
+        results = list(
+            cat.searchResults(
+            reg_number=(applicant.reg_number, applicant.reg_number)))
+        self.assertEqual(applicant,results[0])
         return
 
@@ -813,5 +827,5 @@
         # We change the application mode and check if applicants
         # can find and update imported records instead of creating new records.
-        # First we check what happens if record can't be found.
+        # First we check what happens if record does not exist.
         self.applicantscontainer.mode = 'update'
         self.browser.open(self.container_path + '/register')
@@ -822,5 +836,27 @@
         self.assertTrue('No application record found.'
             in self.browser.contents)
-        # We can't register if password has already been set.
+        # Even with the correct reg_number we can't register
+        # because firstname attribute is not set.
+        self.applicantscontainer.mode = 'update'
+        self.browser.open(self.container_path + '/register')
+        self.browser.getControl(name="form.firstname").value = 'John'
+        self.browser.getControl(name="form.reg_number").value = '1234'
+        self.browser.getControl(name="form.email").value = 'xx@yy.zz'
+        self.browser.getControl("Get login credentials").click()
+        self.assertTrue('An error occurred.' in self.browser.contents)
+        # Let's set this attribute manually
+        # and try to register with a wrong name.
+        self.applicant.firstname = u'John'
+        self.browser.open(self.container_path + '/register')
+        self.browser.getControl(name="form.firstname").value = 'Johnny'
+        self.browser.getControl(name="form.reg_number").value = '1234'
+        self.browser.getControl(name="form.email").value = 'xx@yy.zz'
+        self.browser.getControl("Get login credentials").click()
+        # Anonymous is not informed that firstname verification failed.
+        # It seems that the record doesn't exist.
+        self.assertTrue('No application record found.'
+            in self.browser.contents)
+        # Even with the correct firstname we can't register because
+        # password has already been set.
         self.browser.getControl(name="form.firstname").value = 'John'
         self.browser.getControl(name="form.reg_number").value = '1234'
@@ -833,25 +869,18 @@
             self.applicant.application_number]).context.password = None
         self.browser.open(self.container_path + '/register')
-        self.browser.getControl(name="form.firstname").value = 'John'
+        # The firstname field, used for verification, is not case-sensitive.
+        self.browser.getControl(name="form.firstname").value = 'jOhn'
         self.browser.getControl(name="form.reg_number").value = '1234'
         self.browser.getControl(name="form.email").value = 'xx@yy.zz'
         self.browser.getControl("Get login credentials").click()
-        self.assertTrue('An error occurred.'in self.browser.contents)
-        # The firstname attribute was None. Let's set this attribute manually
-        # and try to register with a wrong name.
-        self.applicant.firstname = u'John'
-        self.browser.open(self.container_path + '/register')
-        self.browser.getControl(name="form.firstname").value = 'Johnny'
-        self.browser.getControl(name="form.reg_number").value = '1234'
-        self.browser.getControl(name="form.email").value = 'xx@yy.zz'
-        self.browser.getControl("Get login credentials").click()
-        self.assertTrue('No application record found.'
-            in self.browser.contents)
-        # Now we use the correct name. For verification
-        # the name is not case-sensitive.
-        self.browser.getControl(name="form.firstname").value = 'jOhn'
-        self.browser.getControl("Get login credentials").click()
+        # Yeah, we succeded ...
         self.assertTrue('Your registration was successful.'
             in self.browser.contents)
+        # ... and  applicant can be found in the catalog via the email address
+        cat = getUtility(ICatalog, name='applicants_catalog')
+        results = list(
+            cat.searchResults(
+            email=('xx@yy.zz', 'xx@yy.zz')))
+        self.assertEqual(self.applicant,results[0])
         return
 
