Index: /main/waeup.sirp/trunk/src/waeup/sirp/applicants/applicant.py
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/applicants/applicant.py	(revision 7259)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/applicants/applicant.py	(revision 7260)
@@ -17,5 +17,4 @@
 ##
 import os
-from random import SystemRandom as r
 import grok
 from grok import index
@@ -34,24 +33,14 @@
     )
 
-def generate_applicant_id(container=None):
-    if container is not None:
-        aid = u"%s_%d" % (container.code, r().randint(99999,1000000))
-        while aid in container.keys():
-            aid = u"%s_%d" % (container.code, r().randint(99999,1000000))
-        return aid
-    else:
-        # In some tests we don't use containers
-        return u"xxx_1234"
-
 class Applicant(grok.Container):
     grok.implements(IApplicant,IApplicantEdit)
     grok.provides(IApplicant)
 
-    def __init__(self, container=None):
+    def __init__(self):
         super(Applicant, self).__init__()
-        self.applicant_id = generate_applicant_id(container)
         self.password = None
         IWorkflowInfo(self).fireTransition('init')
         self.application_date = None
+        self.applicant_id = None
         return
 
@@ -72,5 +61,8 @@
     @property
     def application_number(self):
-        return self.applicant_id.split('_')[1]
+        try:
+            return self.applicant_id.split('_')[1]
+        except AttributeError:
+            return None
 
     @property
@@ -110,5 +102,5 @@
 
     def __call__(self, *args, **kw):
-        return Applicant(kw['container'])
+        return Applicant()
 
     def getInterfaces(self):
Index: /main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py	(revision 7259)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py	(revision 7260)
@@ -424,5 +424,5 @@
     @grok.action('Create application record')
     def addApplicant(self, **data):
-        applicant = createObject(u'waeup.Applicant', container = self.context)
+        applicant = createObject(u'waeup.Applicant')
         self.applyData(applicant, **data)
         self.context.addApplicant(applicant)
Index: /main/waeup.sirp/trunk/src/waeup/sirp/applicants/container.py
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/applicants/container.py	(revision 7259)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/applicants/container.py	(revision 7260)
@@ -19,4 +19,5 @@
 Containers for university applicants.
 """
+from random import SystemRandom as r
 import grok
 from zope.component.factory import Factory
@@ -27,4 +28,14 @@
     )
 from waeup.sirp.utils.helpers import attrs_to_fields
+
+def generate_applicant_id(container=None):
+    if container is not None:
+        aid = u"%s_%d" % (container.code, r().randint(99999,1000000))
+        while aid in container.keys():
+            aid = u"%s_%d" % (container.code, r().randint(99999,1000000))
+        return aid
+    else:
+        # In some tests we don't use containers
+        return u"xxx_1234"
 
 class ApplicantsContainer(grok.Container):
@@ -89,4 +100,6 @@
             raise TypeError(
                 'ApplicantsContainers contain only IApplicant instances')
+        applicant_id = generate_applicant_id(container=self)
+        applicant.applicant_id = applicant_id
         self[applicant.application_number] = applicant
         return
Index: /main/waeup.sirp/trunk/src/waeup/sirp/applicants/interfaces.py
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/applicants/interfaces.py	(revision 7259)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/applicants/interfaces.py	(revision 7260)
@@ -257,5 +257,5 @@
         title = u'Applicant Id',
         required = False,
-        readonly = True,
+        readonly = False,
         )
 
Index: /main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_applicant.py
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_applicant.py	(revision 7259)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_applicant.py	(revision 7260)
@@ -123,9 +123,10 @@
         # we can get an image filename for applicants not in a container
         appl = Applicant()
+        appl.applicant_id = u'dummy_123456'
         chooser = IFileStoreNameChooser(appl)
         result = chooser.chooseName()
         # the file would be stored in a ``_default`` directory.
         self.assertEqual(
-            result, '__img-applicant___default/xxx_1234.jpg')
+            result, '__img-applicant___default/dummy_123456.jpg')
         return
 
@@ -134,5 +135,6 @@
         fake_container.__name__ = 'folder'
         fake_container.code = 'folder'
-        appl = Applicant(container=fake_container)
+        appl = Applicant()
+        appl.applicant_id = u'folder_123456'
         appl.__parent__ = fake_container
         chooser = IFileStoreNameChooser(appl)
@@ -147,5 +149,6 @@
         fake_container.__name__ = 'folder'
         fake_container.code = 'folder'
-        appl = Applicant(container=fake_container)
+        appl = Applicant()
+        appl.applicant_id = u'folder_123456'
         appl.__parent__ = fake_container
         chooser = IFileStoreNameChooser(appl)
@@ -193,5 +196,5 @@
 
     def test_factory(self):
-        obj = self.factory(container=None)
+        obj = self.factory()
         assert isinstance(obj, Applicant)
 
Index: /main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_browser.py
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_browser.py	(revision 7259)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_browser.py	(revision 7260)
@@ -117,7 +117,6 @@
 
         # Add an applicant
-        self.applicant = Applicant(container=applicantscontainer)
-        app['applicants']['app2009'][
-            self.applicant.application_number] = self.applicant
+        self.applicant = Applicant()
+        app['applicants']['app2009'].addApplicant(self.applicant)
         IUserAccount(
             self.app['applicants']['app2009'][
Index: /main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_catalog.py
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_catalog.py	(revision 7259)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_catalog.py	(revision 7260)
@@ -61,7 +61,6 @@
         setSite(self.app)
         self.app['applicants']['mystuff'] = self.container
-        self.applicant = Applicant(container=self.container)
-        self.app['applicants']['mystuff'][
-            self.applicant.application_number] = self.applicant
+        self.applicant = Applicant()
+        self.app['applicants']['mystuff'].addApplicant(self.applicant)
         return
 
