Index: /main/waeup.kofa/trunk/src/waeup/kofa/mandates/mandate.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/mandates/mandate.py	(revision 8846)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/mandates/mandate.py	(revision 8847)
@@ -20,5 +20,7 @@
 """
 import grok
+import hashlib
 from datetime import datetime, timedelta
+from time import time
 from grok import index
 from waeup.kofa.interfaces import IUserAccount
@@ -32,11 +34,14 @@
     grok.provides(IMandate)
 
-    def __init__(self, days=1):
+    def __init__(self, days=1, category=None, mandate_id=None):
         super(Mandate, self).__init__()
         self.creation_date = datetime.utcnow() # offset-naive datetime
         delta = timedelta(days=days)
         self.expires = datetime.utcnow() + delta
-        self.mandate_id = None
-        self.category = None
+        if mandate_id is None:
+            timestamp = "%d" % int(time()*1000)
+            mandate_id = hashlib.md5(timestamp).hexdigest()
+        self.mandate_id = mandate_id
+        self.category = category
         self.params = {}
         return
Index: /main/waeup.kofa/trunk/src/waeup/kofa/mandates/tests.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/mandates/tests.py	(revision 8846)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/mandates/tests.py	(revision 8847)
@@ -85,5 +85,4 @@
         # Add and execute a mandate with missing parameters.
         mandate = Mandate()
-        mandate.mandate_id = '12345'
         mandate.category = 'student_password'
         self.app['mandates'].addMandate(mandate)
@@ -92,5 +91,4 @@
         # Add and execute an expired mandate.
         mandate = Mandate(days=0)
-        mandate.mandate_id = '12345'
         mandate.category = 'student_password'
         self.app['mandates'].addMandate(mandate)
@@ -99,5 +97,4 @@
         # Ad and execute a perfect mandate
         mandate = Mandate(days=0)
-        mandate.mandate_id = '12345'
         mandate.category = 'student_password'
         mandate.params['student_id'] = student.student_id
@@ -114,9 +111,7 @@
         # mandate1 is an old mandate which just expired.
         mandate1 = Mandate(days=0)
-        mandate1.mandate_id = '12345'
         self.app['mandates'].addMandate(mandate1)
         # mandate2 is a new mandate with default time delta.
-        mandate2 = Mandate()
-        mandate2.mandate_id = '23456'
+        mandate2 = Mandate(mandate_id='23456')
         self.app['mandates'].addMandate(mandate2)
         self.assertEqual(len(self.app['mandates'].keys()), 2)
