Changeset 1716
- Timestamp:
- 26 Apr 2007, 19:48:55 (18 years ago)
- Location:
- WAeUP_SRP/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/WAeUPTables.py
r1707 r1716 557 557 ###) 558 558 559 560 559 security.declarePrivate('notify_event_listener') ###( 561 560 def notify_event_listener(self,event_type,object,infos): 562 561 "listen for events" 562 if not infos.has_key('rpath'): 563 return 563 564 pt = getattr(object,'portal_type',None) 564 565 mt = getattr(object,'meta_type',None) … … 573 574 students_catalog.modifyRecord(**data) 574 575 return 575 if pt not in self.affected_types.keys():576 return577 if not infos.has_key('rpath'):578 return579 576 rpl = infos['rpath'].split('/') 580 577 if pt == 'Student' and event_type == "sys_add_object": … … 585 582 pass 586 583 return 587 elif pt == 'CourseResult' and mt == 'CPS Proxy Folder': 588 pass 584 elif pt == 'StudentCourseResult' and mt == 'CPS Proxy Folder': 585 if event_type not in ("sys_add_object","sys_del_object"): 586 return 587 #from pdb import set_trace;set_trace() 588 course_id = object.getId() 589 student_id = object.absolute_url_path().split('/')[-4] 590 res = self(id = student_id) 591 if not res: 592 return 593 student_rec = res[0] 594 registered_courses = student_rec.registered_courses 595 if event_type == "sys_add_object": 596 registered_courses.append(course_id) 597 if event_type == "sys_del_object": 598 registered_courses.remove(course_id) 599 data['id'] = student_id 600 data['registered_courses'] = registered_courses 601 self.modifyRecord(**data) 602 if pt not in self.affected_types.keys(): 603 return 589 604 if event_type not in ('sys_modify_object'): 590 #from pdb import set_trace;set_trace()591 605 return 592 606 if mt == 'CPS Proxy Folder': 593 607 return 594 for field in self.affected_types[pt] :608 for field in self.affected_types[pt]['fields']: 595 609 if hasattr(self,'get_from_doc_%s' % field): 596 610 data[field] = getattr(self,'get_from_doc_%s' % field)(object) … … 598 612 data[field] = getattr(object,field) 599 613 data['id'] = rpl[2] 600 s tudents_catalog.modifyRecord(**data)614 self.modifyRecord(**data) 601 615 ###) 602 616 … … 607 621 608 622 class CoursesCatalog(WAeUPTable): ###( 623 security = ClassSecurityInfo() 609 624 610 625 meta_type = 'WAeUP Courses Catalog' … … 614 629 WAeUPTable.__init__(self, 'courses_catalog') 615 630 631 def manage_catalogReindex(self, REQUEST, RESPONSE, URL1): ###( 632 """ clear the catalog, then re-index everything """ 633 634 elapse = time.time() 635 c_elapse = time.clock() 636 637 pgthreshold = self._getProgressThreshold() 638 handler = (pgthreshold > 0) and ZLogHandler(pgthreshold) or None 639 self.refreshCatalog(clear=1, pghandler=handler) 640 641 elapse = time.time() - elapse 642 c_elapse = time.clock() - c_elapse 643 644 RESPONSE.redirect( 645 URL1 + 646 '/manage_catalogAdvanced?manage_tabs_message=' + 647 urllib.quote('Catalog Updated \n' 648 'Total time: %s\n' 649 'Total CPU time: %s' % (`elapse`, `c_elapse`))) 650 ###) 651 652 def reindexIndex(self, name, REQUEST,pghandler=None): ###( 653 if isinstance(name, str): 654 name = (name,) 655 courses = self.portal_catalog(portal_type="Course") 656 num_objects = len(courses) 657 if pghandler: 658 pghandler.init('Refreshing catalog: %s' % self.absolute_url(1), num_objects) 659 for i in xrange(num_objects): 660 if pghandler: pghandler.report(i) 661 course_brain = courses[i] 662 course_object = course_brain.getObject() 663 pl = course_brain.getPath().split('/') 664 data = {} 665 cid = data[self.key] = course_brain.getId 666 data['faculty'] = pl[-4] 667 data['department'] = pl[-3] 668 doc = course_object.getContent() 669 for field in name: 670 if field not in (self.key,'faculty','department'): 671 data[field] = getattr(doc,field) 672 self.modifyRecord(**data) 673 if pghandler: pghandler.finish() 674 ###) 675 676 def refreshCatalog(self, clear=0, pghandler=None): ###( 677 """ re-index everything we can find """ 678 courses = self.portal_catalog(portal_type="Course") 679 num_objects = len(courses) 680 if pghandler: 681 pghandler.init('Refreshing catalog: %s' % self.absolute_url(1), num_objects) 682 for i in xrange(num_objects): 683 if pghandler: pghandler.report(i) 684 course_brain = courses[i] 685 course_object = course_brain.getObject() 686 pl = course_brain.getPath().split('/') 687 data = {} 688 data[self.key] = course_brain.getId 689 data['faculty'] = pl[-4] 690 data['department'] = pl[-3] 691 doc = course_object.getContent() 692 self.modifyRecord(**data) 693 if pghandler: pghandler.finish() 694 ###) 695 696 security.declarePrivate('notify_event_listener') ###( 697 def notify_event_listener(self,event_type,object,infos): 698 "listen for events" 699 if not infos.has_key('rpath'): 700 return 701 pt = getattr(object,'portal_type',None) 702 mt = getattr(object,'meta_type',None) 703 if pt != 'Course': 704 return 705 #from pdb import set_trace;set_trace() 706 data = {} 707 rpl = infos['rpath'].split('/') 708 if event_type not in ("sys_add_object","sys_modify_object","sys_del_object"): 709 return 710 course_id = object.getId() 711 data[self.key] = course_id 712 if event_type == "sys_add_object": 713 try: 714 self.addRecord(**data) 715 except ValueError: 716 pass 717 if event_type == "sys_del_object": 718 self.deleteRecord(course_id) 719 if event_type == "sys_modify_object" and mt == 'Course': 720 for field in self.schema(): 721 data[field] = getattr(object,field,None) 722 course_id = object.aq_parent.getId() 723 data[self.key] = course_id 724 self.modifyRecord(**data) 725 ###) 726 616 727 617 728 InitializeClass(CoursesCatalog) -
WAeUP_SRP/trunk/WAeUPTool.py
r1707 r1716 68 68 response.write("%s<br />\r\n" % s) 69 69 70 security.declareProtected(ModifyPortalContent,'openLog') 71 def openLog(self,name): 72 """open a log file""" 73 version = 1 74 path = "%s/log/%s_%d.log" % (i_home,name,version) 75 while os.path.exists(path): 76 version += 1 77 path = "%s/log/%s_%d.log" % (i_home,name,version) 78 log = open(path,"w") 79 return log 80 81 security.declareProtected(ModifyPortalContent,'writeLog') 82 def writeLog(self,logfile,s): 83 """write to the log file""" 84 logfile.write(s) 85 86 70 87 def generateStudentId(self,letter): ###( 71 88 import random -
WAeUP_SRP/trunk/profiles/default/courses_catalog.xml
r1410 r1716 6 6 <column value="department"/> 7 7 <column value="title"/> 8 <column value="level"/>9 8 <column value="credits"/> 10 9 <column value="passmark"/> … … 19 18 <indexed_attr value="department"/> 20 19 </index> 21 <index name="level" meta_type="KeywordIndex">22 <indexed_attr value="level"/>23 </index>24 20 </object> -
WAeUP_SRP/trunk/skins/waeup_default/waeup_document_create_do.py
r1366 r1716 34 34 if new_id is not None: 35 35 id = new_id 36 if type_name == "Course": 36 if type_name == "Course": # disable if handled by event 37 37 d = {} 38 38 ptl = request.get('PATH_TRANSLATED').split('/') -
WAeUP_SRP/trunk/skins/waeup_default/waeup_edit.py
r1571 r1716 102 102 ) 103 103 logger.info('%s edited %s of %s' % (member,context.id,student_id)) 104 elif context.portal_type == "Course": 104 elif context.portal_type == "Course": # disable if handled by events 105 105 dd = {} 106 106 dd.update(ds) # ds is not a real dictionary
Note: See TracChangeset for help on using the changeset viewer.