Index: main/waeup.sirp/trunk/src/waeup/sirp/university/export.py
===================================================================
--- main/waeup.sirp/trunk/src/waeup/sirp/university/export.py	(revision 7753)
+++ main/waeup.sirp/trunk/src/waeup/sirp/university/export.py	(revision 7756)
@@ -18,8 +18,10 @@
         """Hook for mangling values in derived classes
         """
-        if isinstance(value, unicode):
+        if isinstance(value, bool):
+            value = value and '1' or '0'
+        elif isinstance(value, unicode):
             # CSV writers like byte streams better than unicode
             value = value.encode('utf-8')
-        if value is None:
+        elif value is None:
             # None is not really representable in CSV files
             value = ''
@@ -181,2 +183,47 @@
                     self.write_item(cert, writer)
         return self.close_outfile(filepath, outfile)
+
+class CertificateCourseExporter(CourseExporter, grok.GlobalUtility):
+    """Exporter for courses.
+    """
+    grok.implements(ICSVExporter)
+    grok.name('certificate_courses')
+
+    #: Fieldnames considered by this exporter
+    fields = ('course', 'faculty_code', 'department_code', 'certificate_code',
+              'level', 'mandatory')
+
+    def mangle_value(self, value, name, context=None):
+        """Hook for mangling values in derived classes
+        """
+        if name == 'faculty_code':
+            try:
+                value = context.__parent__.__parent__.__parent__.__parent__.code
+            except AttributeError:
+                value = None
+        elif name == 'department_code':
+            try:
+                value = context.__parent__.__parent__.__parent__.code
+            except AttributeError:
+                value = None
+        elif name == 'certificate_code':
+            value = getattr(context, '__parent__', None)
+            value = getattr(value, 'code', None)
+        if name == 'course':
+            value = getattr(value, 'code', None)
+        return super(CourseExporter, self).mangle_value(
+            value, name, context)
+
+    def export_all(self, site, filepath=None):
+        """Export faculties in facultycontainer into filepath as CSV data.
+
+        If `filepath` is ``None``, a raw string with CSV data is returned.
+        """
+        writer, outfile = self.get_csv_writer(filepath)
+        faculties = site.get('faculties', {})
+        for faculty in faculties.values():
+            for department in faculty.values():
+                for cert in department.certificates.values():
+                    for certref in cert.values():
+                        self.write_item(certref, writer)
+        return self.close_outfile(filepath, outfile)
Index: main/waeup.sirp/trunk/src/waeup/sirp/university/tests/test_export.py
===================================================================
--- main/waeup.sirp/trunk/src/waeup/sirp/university/tests/test_export.py	(revision 7753)
+++ main/waeup.sirp/trunk/src/waeup/sirp/university/tests/test_export.py	(revision 7756)
@@ -12,5 +12,5 @@
 from waeup.sirp.university.export import (
     FacultyExporter, DepartmentExporter, CourseExporter,
-    CertificateExporter,
+    CertificateExporter, CertificateCourseExporter,
     )
 
@@ -391,2 +391,114 @@
             )
         return
+
+class CertificateCourseExporterTest(unittest.TestCase):
+    # Tests for CertificateCourseExporter
+
+    layer = SIRPUnitTestLayer
+
+    def setUp(self):
+        self.workdir = tempfile.mkdtemp()
+        self.outfile = os.path.join(self.workdir, 'myoutput.csv')
+        # create some departments and courses in a fake site
+        container = FacultiesContainer()
+        self.site = {'faculties':container}
+        self.fac = Faculty('Faculty of Cheese', 'faculty', 'F1')
+        container.addFaculty(self.fac)
+        self.dept1 = Department('Department of Cheddar', 'department', 'D1')
+        self.dept2 = Department('Institue of Gouda', 'institute', 'D2')
+        self.fac.addDepartment(self.dept1)
+        self.fac.addDepartment(self.dept2)
+        self.course1 = Course('Cheese Basics', 'C1')
+        self.course2 = Course('Advanced Cheese Making', 'C2')
+        self.course3 = Course('Selling Cheese', 'C3')
+        self.dept1.courses.addCourse(self.course1)
+        self.dept1.courses.addCourse(self.course2)
+        self.dept2.courses.addCourse(self.course3)
+        self.cert1 = Certificate(
+            'CERT1', 'Master of Cheese', study_mode=u'ct_ft', start_level=100,
+            end_level=300, application_category='basic')
+        self.cert2 = Certificate(
+            'CERT2', 'Master of Cheddar', study_mode='ct_ft', start_level=400,
+            end_level=700, application_category='cest')
+        self.cert3 = Certificate(
+            'CERT3', 'Cert. of Rubbish', study_mode='dp_pt', start_level=100,
+            end_level=200, application_category='no')
+        self.dept1.certificates.addCertificate(self.cert1)
+        self.dept1.certificates.addCertificate(self.cert2)
+        self.dept2.certificates.addCertificate(self.cert3)
+        self.cert1.addCourseRef(self.course1, 100, True)
+        self.cert1.addCourseRef(self.course2, 400, False)
+        self.cert3.addCourseRef(self.course3, 100, False)
+        self.certcourse1 = self.cert1['C1_100']
+        self.certcourse2 = self.cert1['C2_400']
+        self.certcourse3 = self.cert3['C3_100']
+        return
+
+    def tearDown(self):
+        shutil.rmtree(self.workdir)
+        return
+
+    def test_ifaces(self):
+        # make sure we fullfill interface contracts
+        obj = CertificateCourseExporter()
+        verifyObject(ICSVExporter, obj)
+        verifyClass(ICSVExporter, CertificateCourseExporter)
+        return
+
+    def test_get_as_utility(self):
+        # we can get a certificate exporter as utility
+        result = queryUtility(ICSVExporter, name="certificate_courses")
+        self.assertTrue(result is not None)
+        return
+
+    def test_export(self):
+        # we can export an iterable of certificates
+        exporter = CertificateCourseExporter()
+        exporter.export([self.certcourse1], self.outfile)
+        result = open(self.outfile, 'rb').read()
+        self.assertEqual(
+            result,
+            'course,faculty_code,department_code,certificate_code,level,mandatory\r\n'
+            'C1,F1,D1,CERT1,100,1\r\n'
+            )
+        return
+
+    def test_export_to_string(self):
+        # we can export an iterable of certificates to a string.
+        exporter = CertificateCourseExporter()
+        result = exporter.export(
+            [self.certcourse1, self.certcourse2], filepath=None)
+        self.assertEqual(
+            result,
+            'course,faculty_code,department_code,certificate_code,level,mandatory\r\n'
+            'C1,F1,D1,CERT1,100,1\r\n'
+            'C2,F1,D1,CERT1,400,0\r\n'
+            )
+        return
+
+    def test_export_all(self):
+        # we can export all certificates in a site
+        exporter = CertificateCourseExporter()
+        exporter.export_all(self.site, self.outfile)
+        result = open(self.outfile, 'rb').read()
+        self.assertEqual(
+            result,
+            'course,faculty_code,department_code,certificate_code,level,mandatory\r\n'
+            'C1,F1,D1,CERT1,100,1\r\n'
+            'C2,F1,D1,CERT1,400,0\r\n'
+            'C3,F1,D2,CERT3,100,0\r\n'
+            )
+        return
+
+    def test_export_all_to_string(self):
+        # we can export all certificates in a site to a string
+        exporter = CertificateCourseExporter()
+        result = exporter.export_all(self.site, filepath=None)
+        self.assertEqual(
+            result,
+            'course,faculty_code,department_code,certificate_code,level,mandatory\r\n'
+            'C1,F1,D1,CERT1,100,1\r\n'
+            'C2,F1,D1,CERT1,400,0\r\n'
+            'C3,F1,D2,CERT3,100,0\r\n'
+            )
+        return
