Index: /waeup/branches/ulif-rewrite/src/waeup/university/certificate.py
===================================================================
--- /waeup/branches/ulif-rewrite/src/waeup/university/certificate.py	(revision 4483)
+++ /waeup/branches/ulif-rewrite/src/waeup/university/certificate.py	(revision 4484)
@@ -3,4 +3,6 @@
 import grok
 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
+from zope.app.catalog.interfaces import ICatalog
+from zope.component import getUtility
 from zope.component.interfaces import IFactory
 from zope.interface import implementedBy
@@ -52,6 +54,8 @@
         """Delete a course denoted by its code.
         """
-        if code in self.keys():
-            del self[code]
+        for key in self.keys():
+            if self[key].getCourseCode != code:
+                continue
+            del self[key]
             self._p_changed = True
         return
@@ -104,16 +108,13 @@
        certificatecontainer are removed.
     """
-    old_parent = event.oldParent
     code = course.code
-    # Try to find a nearby certificate container...
-    dept = getattr(old_parent, '__parent__', None)
-    if not IDepartment.providedBy(dept):
-        # Hm, looks like this course was not part of a department...
-        return
-    certcontainer = dept.certificates
-    for cert in certcontainer.values():
-        # Loop through all certificatecourses in this certificate...
-        if code in cert.keys():
-            del cert[code]
-            cert._p_changed = True
 
+    # Find all certcourses that reference the given course...
+    cat = getUtility(ICatalog, name='certcourses_catalog')
+    results = cat.searchResults(course_code=(code, code))
+    for certcourse in results:
+        # Remove that reference...
+        cert = certcourse.__parent__
+        cert.delCourseRef(code)
+        cert._p_changed = True
+    return
