Index: /WAeUP_SRP/trunk/WAeUPTables.py
===================================================================
--- /WAeUP_SRP/trunk/WAeUPTables.py	(revision 1715)
+++ /WAeUP_SRP/trunk/WAeUPTables.py	(revision 1716)
@@ -557,8 +557,9 @@
     ###)
 
-
     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)
@@ -573,8 +574,4 @@
             students_catalog.modifyRecord(**data)
             return
-        if pt not in self.affected_types.keys():
-            return
-        if not infos.has_key('rpath'):
-            return
         rpl = infos['rpath'].split('/')
         if pt == 'Student' and event_type == "sys_add_object":
@@ -585,12 +582,29 @@
                 pass
             return
-        elif pt == 'CourseResult' and mt == 'CPS Proxy Folder':
-            pass
+        elif pt == 'StudentCourseResult' and mt == 'CPS Proxy Folder':
+            if event_type not in ("sys_add_object","sys_del_object"):
+                return
+            #from pdb import set_trace;set_trace()
+            course_id = object.getId()
+            student_id = object.absolute_url_path().split('/')[-4]
+            res = self(id = student_id)
+            if not res:
+                return
+            student_rec = res[0]
+            registered_courses = student_rec.registered_courses
+            if event_type == "sys_add_object":
+                registered_courses.append(course_id)
+            if event_type == "sys_del_object":
+                registered_courses.remove(course_id)
+            data['id'] = student_id
+            data['registered_courses'] = registered_courses
+            self.modifyRecord(**data)
+        if pt not in self.affected_types.keys():
+            return
         if event_type not in ('sys_modify_object'):
-            #from pdb import set_trace;set_trace()
             return
         if mt == 'CPS Proxy Folder':
             return
-        for field in self.affected_types[pt]:
+        for field in self.affected_types[pt]['fields']:
             if hasattr(self,'get_from_doc_%s' % field):
                 data[field] = getattr(self,'get_from_doc_%s' % field)(object)
@@ -598,5 +612,5 @@
                 data[field] = getattr(object,field)
         data['id'] = rpl[2]
-        students_catalog.modifyRecord(**data)
+        self.modifyRecord(**data)
     ###)
 
@@ -607,4 +621,5 @@
 
 class CoursesCatalog(WAeUPTable): ###(
+    security = ClassSecurityInfo()
 
     meta_type = 'WAeUP Courses Catalog'
@@ -614,4 +629,100 @@
         WAeUPTable.__init__(self, 'courses_catalog')
 
+    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,)
+        courses = self.portal_catalog(portal_type="Course")
+        num_objects = len(courses)
+        if pghandler:
+            pghandler.init('Refreshing catalog: %s' % self.absolute_url(1), num_objects)
+        for i in xrange(num_objects):
+            if pghandler: pghandler.report(i)
+            course_brain = courses[i]
+            course_object = course_brain.getObject()
+            pl = course_brain.getPath().split('/')
+            data = {}
+            cid = data[self.key] = course_brain.getId
+            data['faculty'] = pl[-4]
+            data['department'] = pl[-3]
+            doc = course_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 """
+        courses = self.portal_catalog(portal_type="Course")
+        num_objects = len(courses)
+        if pghandler:
+            pghandler.init('Refreshing catalog: %s' % self.absolute_url(1), num_objects)
+        for i in xrange(num_objects):
+            if pghandler: pghandler.report(i)
+            course_brain = courses[i]
+            course_object = course_brain.getObject()
+            pl = course_brain.getPath().split('/')
+            data = {}
+            data[self.key] = course_brain.getId
+            data['faculty'] = pl[-4]
+            data['department'] = pl[-3]
+            doc = course_object.getContent()
+            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 != 'Course':
+            return
+        #from pdb import set_trace;set_trace()
+        data = {}
+        rpl = infos['rpath'].split('/')
+        if event_type not in ("sys_add_object","sys_modify_object","sys_del_object"):
+            return
+        course_id = object.getId()
+        data[self.key] = course_id
+        if event_type == "sys_add_object":
+            try:
+                self.addRecord(**data)
+            except ValueError:
+                pass
+        if event_type == "sys_del_object":
+            self.deleteRecord(course_id)
+        if event_type == "sys_modify_object" and mt == 'Course':
+            for field in self.schema():
+                data[field] = getattr(object,field,None) 
+            course_id = object.aq_parent.getId()
+            data[self.key] = course_id
+            self.modifyRecord(**data)
+    ###)
+
 
 InitializeClass(CoursesCatalog)
Index: /WAeUP_SRP/trunk/WAeUPTool.py
===================================================================
--- /WAeUP_SRP/trunk/WAeUPTool.py	(revision 1715)
+++ /WAeUP_SRP/trunk/WAeUPTool.py	(revision 1716)
@@ -68,4 +68,21 @@
         response.write("%s<br />\r\n" % s)
 
+    security.declareProtected(ModifyPortalContent,'openLog') 
+    def openLog(self,name):
+        """open a log file"""
+        version = 1
+        path = "%s/log/%s_%d.log" % (i_home,name,version)
+        while os.path.exists(path):
+            version += 1
+            path = "%s/log/%s_%d.log" % (i_home,name,version)
+        log = open(path,"w")
+        return log
+
+    security.declareProtected(ModifyPortalContent,'writeLog') 
+    def writeLog(self,logfile,s):
+        """write to the log file"""
+        logfile.write(s)
+
+        
     def generateStudentId(self,letter): ###(
         import random
Index: /WAeUP_SRP/trunk/profiles/default/courses_catalog.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/courses_catalog.xml	(revision 1715)
+++ /WAeUP_SRP/trunk/profiles/default/courses_catalog.xml	(revision 1716)
@@ -6,5 +6,4 @@
  <column value="department"/>
  <column value="title"/>
- <column value="level"/>
  <column value="credits"/>
  <column value="passmark"/>
@@ -19,6 +18,3 @@
   <indexed_attr value="department"/>
  </index>
- <index name="level" meta_type="KeywordIndex">
-  <indexed_attr value="level"/>
- </index>
 </object>
Index: /WAeUP_SRP/trunk/skins/waeup_default/waeup_document_create_do.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_default/waeup_document_create_do.py	(revision 1715)
+++ /WAeUP_SRP/trunk/skins/waeup_default/waeup_document_create_do.py	(revision 1716)
@@ -34,5 +34,5 @@
 if new_id is not None:
     id = new_id
-if type_name == "Course":
+if type_name == "Course": # disable if  handled by event
     d = {}
     ptl = request.get('PATH_TRANSLATED').split('/')
Index: /WAeUP_SRP/trunk/skins/waeup_default/waeup_edit.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_default/waeup_edit.py	(revision 1715)
+++ /WAeUP_SRP/trunk/skins/waeup_default/waeup_edit.py	(revision 1716)
@@ -102,5 +102,5 @@
                                              )
         logger.info('%s edited %s of %s' % (member,context.id,student_id))
-    elif context.portal_type == "Course":
+    elif context.portal_type == "Course": # disable if handled by events
         dd = {}
         dd.update(ds) # ds is not a real dictionary
