Index: main/waeup.sirp/trunk/src/waeup/sirp/applicants/applicant.py
===================================================================
--- main/waeup.sirp/trunk/src/waeup/sirp/applicants/applicant.py	(revision 7341)
+++ main/waeup.sirp/trunk/src/waeup/sirp/applicants/applicant.py	(revision 7344)
@@ -80,25 +80,35 @@
 
     def createStudent(self):
-        """Create a student object based on the applicant base data
-        and copy applicant object.
-        """
+        """Create a student, fill with base data, create a StudentApplication
+        object and copy applicant data.
+        """
+        # Is applicant in the correct state?
+        if self.state != 'admitted':
+            return False, "Applicant has not yet been admitted."
+        # Does registration number exist?
         student = createObject(u'waeup.Student')
-        # Check first if registration number exists
         try:
             student.reg_number = self.reg_number
         except RegNumNotInSource:
             return False, 'Registration Number exists.'
-        catalog = getUtility(ICatalog, name='certificates_catalog')
-        #import pdb; pdb.set_trace()
-        code = self.course_admitted['code']
+        # Has the course_admitted field been properly filled?
+        code = self.course_admitted.get('code')
         if code:
+            catalog = getUtility(ICatalog, name='certificates_catalog')
             cert = [i for i in catalog.searchResults(code=(code,code))][0]
         else:
             return False, 'No course admitted provided.'
+        # Add student object
         site = grok.getSite()
         site['students'].addStudent(student)
+        # Fill student_id
+        self.student_id = student.student_id
+        # Fire transition 'create'
+        IWorkflowInfo(self).fireTransition('create')
+
         # TODO: Split fullname in students package and copy first,
-        # middle and lastaname
-        
+        # middle and lastname
+
+        # Copy some base data
         student.fullname = self.fullname
         student.sex = self.sex
@@ -106,8 +116,11 @@
         student.email = self.email
         student.phone = self.phone
+        # Save the certificate
         student['studycourse'].certificate = cert
+        # Create StudentApplication object ...
+        application = createObject(u'waeup.StudentApplication')
+        # ... copy applicant base data
         form_fields = grok.AutoFields(IApplicantBaseData)
         field_names = [i.__name__ for i in form_fields]
-        application = createObject(u'waeup.StudentApplication')
         for name in field_names:
             value = getattr(self,name,None)
@@ -115,5 +128,5 @@
                 setattr(application,name,value)
         site['students'][student.student_id]['application'] = application
-        return True, 'Student with Id %s created' % student.student_id
+        return True, 'Student %s created' % student.student_id
 
 # Set all attributes of Applicant required in IApplicant as field
Index: main/waeup.sirp/trunk/src/waeup/sirp/applicants/dynamicroles.py
===================================================================
--- main/waeup.sirp/trunk/src/waeup/sirp/applicants/dynamicroles.py	(revision 7341)
+++ 	(revision )
@@ -1,46 +1,0 @@
-## $Id$
-##
-## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
-## This program is free software; you can redistribute it and/or modify
-## it under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 2 of the License, or
-## (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-##
-"""Security policy components for applicants.
-
-Applicants need special security policy treatment, as officers with
-local roles for departments and faculties might have additional
-permissions (local roles on depts/faculties) here.
-"""
-import grok
-from zope.securitypolicy.interfaces import IPrincipalRoleManager
-from waeup.sirp.applicants.interfaces import IApplicant
-from waeup.sirp.students.dynamicroles import StudentPrincipalRoleManager
-
-# All components in here have the same context: Applicant instances
-grok.context(IApplicant)
-
-class ApplicantPrincipalRoleManager(StudentPrincipalRoleManager):
-
-    grok.provides(IPrincipalRoleManager)
-
-    #: The attribute name to lookup for additional roles
-    extra_attrib = 'course1'
-    subcontainer = None
-
-    # Role name mapping:
-    # role name to look for in `extra_attrib` and parents
-    # to
-    # role to add in case this role was found
-    rolename_mapping = {
-        'waeup.local.ClearanceOfficer':'waeup.ApplicationsOfficer',
-        }
Index: main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_dynamicroles.py
===================================================================
--- main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_dynamicroles.py	(revision 7341)
+++ 	(revision )
@@ -1,85 +1,0 @@
-## $Id$
-##
-## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
-## This program is free software; you can redistribute it and/or modify
-## it under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 2 of the License, or
-## (at your option) any later version.
-##
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-## GNU General Public License for more details.
-##
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-##
-"""
-Tests for dynamic roles concerning applicants and related.
-"""
-from zope.interface import verify
-from zope.securitypolicy.interfaces import IPrincipalRoleManager
-from zope.securitypolicy.settings import Allow
-from zope.securitypolicy.tests.test_annotationprincipalrolemanager import (
-    Test as APRMTest, Manageable)
-from waeup.sirp.testing import FunctionalLayer
-from waeup.sirp.applicants.tests.test_browser import ApplicantsFullSetup
-from waeup.sirp.applicants import ApplicantPrincipalRoleManager
-
-class ApplicantPrincipalRoleManagerTests(APRMTest):
-    # Make sure our PRM behaves like a regular one for usual cases.
-    # Usual cases are ones, that do not interact with external officers.
-    # See next test case for functional tests including officer perms.
-
-    def _make_roleManager(self, obj=None):
-        # Overriding this method of original testcase we make sure
-        # that really an Applicant PRM is tested.
-        if obj is None:
-            obj = Manageable()
-        return ApplicantPrincipalRoleManager(obj)
-
-class ApplicantPrincipalRoleManagerFunctionalTests(ApplicantsFullSetup):
-
-    layer = FunctionalLayer
-
-    def setUp(self):
-        super(ApplicantPrincipalRoleManagerFunctionalTests, self).setUp()
-        self.applicant.course1 = self.certificate
-        self.officer_role = 'waeup.ApplicationsOfficer'
-        # assign clearance permissions for a virtual officer
-        prm = IPrincipalRoleManager(self.department)
-        prm.assignRoleToPrincipal('waeup.local.ClearanceOfficer', 'alice')
-        return
-
-    def test_iface(self):
-        # make sure out ApplicantPRM really implements required ifaces.
-        obj = ApplicantPrincipalRoleManager(self.applicant)
-        verify.verifyClass(IPrincipalRoleManager,
-                           ApplicantPrincipalRoleManager)
-        verify.verifyObject(IPrincipalRoleManager, obj)
-        return
-
-    def test_get_as_adapter(self):
-        # we can get an ApplicantPRM for Applicants by adapter lookup
-        prm = IPrincipalRoleManager(self.applicant)
-        self.assertTrue(
-            isinstance(prm, ApplicantPrincipalRoleManager))
-        return
-
-    def test_no_officer_set(self):
-        # if the faculty/dept. of the connected cert has no local
-        # roles set, we won't get any additional roles for our
-        # applicant
-        prm = IPrincipalRoleManager(self.applicant)
-        result = prm.getRolesForPrincipal('bob')
-        self.assertEqual(result, [])
-        return
-
-    def test_valid_officer(self):
-        # for an officer that has clearance role on the connected dept
-        # we get the ApplicationsOfficer role on our applicant
-        prm = IPrincipalRoleManager(self.applicant)
-        result = prm.getRolesForPrincipal('alice')
-        self.assertEqual(result, [('waeup.ApplicationsOfficer', Allow)])
-        return
