Index: WAeUP_SRP/base/WAeUPTables.py
===================================================================
--- WAeUP_SRP/base/WAeUPTables.py	(revision 3353)
+++ WAeUP_SRP/base/WAeUPTables.py	(revision 3354)
@@ -921,5 +921,5 @@
         if doc is None:
             return None
-        if self._v_certificates.has_key(doc.study_course):
+        if hasattr(self,"_v_certificates") and self._v_certificates.has_key(doc.study_course):
             return self._v_certificates[doc.study_course]['department']
         certificate_res = self.portal_catalog(id = doc.study_course)
@@ -932,5 +932,5 @@
         if doc is None:
             return None
-        if self._v_certificates.has_key(doc.study_course):
+        if hasattr(self,"_v_certificates") and self._v_certificates.has_key(doc.study_course):
             return self._v_certificates[doc.study_course]['faculty']
         certificate_res = self.portal_catalog(id = doc.study_course)
@@ -943,5 +943,5 @@
         if doc is None:
             return None
-        if self._v_certificates.has_key(doc.study_course):
+        if hasattr(self,"_v_certificates") and self._v_certificates.has_key(doc.study_course):
             return self._v_certificates[doc.study_course]['end_level']
         certificate_res = self.portal_catalog(id = doc.study_course)
@@ -1179,9 +1179,8 @@
         if event_type not in ('sys_modify_object'):
             return
-        if pt == 'StudentStudyCourse' and mt == 'CPS Proxy Folder':
-            if not hasattr(self,'_v_certificates'):
-                self._v_certificates = self.fill_certificates_dict()
         if mt == 'CPS Proxy Folder':
             return
+        if not hasattr(self,'_v_certificates'):
+            self._v_certificates = self.fill_certificates_dict()
         for field in self.affected_types[pt]['fields']:
             if hasattr(self,'get_from_doc_%s' % field):
@@ -1196,4 +1195,139 @@
 InitializeClass(StudentsCatalog)
 
+###)
+
+class CertificatesCatalog(WAeUPTable): ###(
+    security = ClassSecurityInfo()
+
+    meta_type = 'WAeUP Certificates Catalog'
+    name =  "certificates_catalog"
+    key = "code"
+    def __init__(self,name=None):
+        if name ==  None:
+            name =  self.name
+        WAeUPTable.__init__(self, name)
+
+    def manage_catalogReindex(self, REQUEST, RESPONSE, URL1): ###(
+        """ clear the catalog, then re-index everything """
+
+        elapse = time.time()
+        c_elapse = time.clock()
+
+        pgthreshold = self._getProgressThreshold()
+        handler = (pgthreshold > 0) and ZLogHandler(pgthreshold) or None
+        self.refreshCatalog(clear=1, pghandler=handler)
+
+        elapse = time.time() - elapse
+        c_elapse = time.clock() - c_elapse
+
+        RESPONSE.redirect(
+            URL1 +
+            '/manage_catalogAdvanced?manage_tabs_message=' +
+            urllib.quote('Catalog Updated \n'
+                         'Total time: %s\n'
+                         'Total CPU time: %s' % (`elapse`, `c_elapse`)))
+    ###)
+
+    def reindexIndex(self, name, REQUEST,pghandler=None): ###(
+        if isinstance(name, str):
+            name = (name,)
+        certificates = self.portal_catalog(portal_type="Certificate")
+        num_objects = len(Certificates)
+        if pghandler:
+            pghandler.init('Refreshing catalog: %s' % self.absolute_url(1), num_objects)
+        for i in xrange(num_objects):
+            if pghandler: pghandler.report(i)
+            certificate_brain = certificates[i]
+            certificate_object = certificate_brain.getObject()
+            pl = certificate_brain.getPath().split('/')
+            data = {}
+            cid = data[self.key] = certificate_brain.getId
+            data['faculty'] = pl[-4]
+            data['department'] = pl[-3]
+            doc = certificate_object.getContent()
+            for field in name:
+                if field not in (self.key,'faculty','department'):
+                    data[field] = getattr(doc,field)
+            self.modifyRecord(**data)
+        if pghandler: pghandler.finish()
+    ###)
+
+    def refreshCatalog(self, clear=0, pghandler=None): ###(
+        """ re-index everything we can find """
+        if clear:
+            self._catalog.clear()
+        certificates = self.portal_catalog(portal_type="Certificate")
+        num_objects = len(certificates)
+        if pghandler:
+            pghandler.init('Refreshing catalog: %s' % self.absolute_url(1), num_objects)
+        #from pdb import set_trace;set_trace()
+        for i in xrange(num_objects):
+            if pghandler: pghandler.report(i)
+            certificate_brain = certificates[i]
+            certificate_doc = certificate_brain.getObject().getContent()
+            pl = certificate_brain.getPath().split('/')
+            data = {}
+            for field in self.schema():
+                data[field] = getattr(certificate_doc,field,None)
+            data[self.key] = certificate_brain.getId
+            ai = pl.index('academics')
+            data['faculty'] = pl[ai +1]
+            data['department'] = pl[ai +2]
+            if clear:
+                self.addRecord(**data)
+            else:
+                self.modifyRecord(**data)
+        if pghandler: pghandler.finish()
+    ###)
+
+    security.declarePrivate('notify_event_listener') ###(
+    def notify_event_listener(self,event_type,object,infos):
+        "listen for events"
+        if not infos.has_key('rpath'):
+            return
+        pt = getattr(object,'portal_type',None)
+        mt = getattr(object,'meta_type',None)
+        if pt != 'Certificate':
+            return
+        data = {}
+        rpl = infos['rpath'].split('/')
+        if event_type not in ("sys_add_object","sys_modify_object","sys_del_object"):
+            return
+        certificate_id = object.getId()
+        data[self.key] = certificate_id
+        if event_type == "sys_add_object" and mt == 'CPS Proxy Folder':
+            try:
+                self.addRecord(**data)
+            except ValueError:
+                return
+            certificate_id = object.getId()
+            doc = object.getContent()
+            if doc is None:
+                return
+            for field in self.schema():
+                data[field] = getattr(doc,field,None)
+            data[self.key] = certificate_id
+            ai = rpl.index('academics')
+            data['faculty'] = rpl[ai +1]
+            data['department'] = rpl[ai +2]
+            self.modifyRecord(**data)
+            return
+        if event_type == "sys_del_object":
+            self.deleteRecord(certificate_id)
+            return
+        if event_type == "sys_modify_object" and mt == 'Certificate':
+            #from pdb import set_trace;set_trace()
+            for field in self.schema():
+                data[field] = getattr(object,field,None)
+            certificate_id = object.aq_parent.getId()
+            data[self.key] = certificate_id
+            ai = rpl.index('academics')
+            data['faculty'] = rpl[ai +1]
+            data['department'] = rpl[ai +2]
+            self.modifyRecord(**data)
+    ###)
+
+
+InitializeClass(CertificatesCatalog)
 ###)
 
