Changeset 1702
- Timestamp:
- 24 Apr 2007, 13:52:06 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/WAeUPTables.py
r1700 r1702 32 32 p_home = Globals.package_home(globals()) 33 33 i_home = Globals.INSTANCE_HOME 34 from Products.AdvancedQuery import Eq, Between, Le,In 34 35 35 36 from interfaces import IWAeUPTable … … 355 356 return None 356 357 return getattr(doc,'current_verdict',None) 357 358 ###) 358 ###) 359 360 def reindexIndex(self, name, REQUEST,pghandler=None): ###( 361 if isinstance(name, str): 362 name = (name,) 363 reindextypes = {} 364 reindex_special = [] 365 #import pdb;pdb.set_trace() 366 for n in name: 367 if n in ("review_state","registered_courses"): 368 reindex_special.append(n) 369 else: 370 for pt in self.affected_types.keys(): 371 if n in self.affected_types[pt]: 372 if reindextypes.has_key(pt): 373 reindextypes[pt].append(n) 374 else: 375 reindextypes[pt]= [n] 376 break 377 students = self.portal_catalog(portal_type="Student") 378 aq_portal = self.portal_catalog.evalAdvancedQuery 379 num_objects = len(students) 380 if pghandler: 381 pghandler.init('Refreshing catalog: %s' % self.absolute_url(1), num_objects) 382 noattr = set(('StudentClearance','StudentPersonal')) & set(reindextypes.keys()) 383 for i in xrange(num_objects): 384 if pghandler: pghandler.report(i) 385 student_brain = students[i] 386 data = {} 387 modified = False 388 sid = data['id'] = student_brain.getId 389 if reindex_special and 'review_state' in reindex_special: 390 modified = True 391 data['review_state'] = student_brain.review_state 392 if reindextypes: 393 query = Eq('path',student_brain.getPath()) 394 sub_brains = aq_portal(query) 395 modified = True 396 spath = student_brain.getPath() 397 if len(sub_brains) > 1: 398 for sub_brain in sub_brains: 399 if not sub_brain.portal_type in reindextypes.keys(): 400 continue 401 doc = sub_brain.getObject().getContent() 402 for field in self.affected_types[sub_brain.portal_type]: 403 if hasattr(self,'get_from_doc_%s' % field): 404 data[field] = getattr(self,'get_from_doc_%s' % field)(doc) 405 else: 406 data[field] = getattr(doc,field) 407 elif len(sub_brains) == 1 and noattr: 408 import_res = self.returning_import(id = sid) 409 if not import_res: 410 continue 411 import_record = import_res[0] 412 data['matric_no'] = import_record.matric_no 413 data['sex'] = import_record.Sex == 'F' 414 data['name'] = "%s %s %s" % (import_record.Firstname, 415 import_record.Middlename, 416 import_record.Lastname) 417 data['matric_no'] = import_record.Entryregno 418 if reindex_special and 'registered_courses' in reindex_special: 419 query = Eq('id','study_course') & Eq('path',student_brain.getPath()) 420 brains = aq_portal(query) 421 while brains: 422 study_course_path = brains[0].getPath() 423 level_brains = self.portal_catalog(path = study_course_path, 424 portal_type = "StudentStudyLevel") 425 if not level_brains: 426 break 427 modified = True 428 level_ids = [l.getId for l in level_brains] 429 level_ids.sort() 430 for l in level_brains: 431 if l.getId == level_ids[-1]: 432 level_path = l.getPath() 433 break 434 result_brains = self.portal_catalog(path = level_path, 435 portal_type = "StudentCourseResult") 436 course_ids = [cr.getId for cr in result_brains] 437 courses = [] 438 for c in course_ids: 439 if c.endswith('_co'): 440 courses.append(c[:-3]) 441 else: 442 courses.append(c) 443 data['registered_courses'] = courses 444 break 445 if modified: 446 self.modifyRecord(**data) 447 if pghandler: pghandler.finish() 448 ###) 359 449 360 450 def refreshCatalog(self, clear=0, pghandler=None): ###( … … 422 512 def notify_event_listener(self,event_type,object,infos): 423 513 "listen for events" 424 pt = object.portal_type425 mt = object.meta_type514 pt = getattr(object,'portal_type',None) 515 mt = getattr(object,'meta_type',None) 426 516 students_catalog = self.students_catalog 517 data = {} 518 if pt == 'Student' and\ 519 mt == 'CPS Proxy Folder' and\ 520 event_type.startswith('workflow'): 521 data['id'] = object.getId() 522 data['review_state'] = self.portal_workflow.getInfoFor(object,'review_state',None) 523 #from pdb import set_trace;set_trace() 524 students_catalog.modifyRecord(**data) 525 return 427 526 if pt not in self.affected_types.keys(): 428 527 return … … 441 540 442 541 if event_type not in ('sys_modify_object'): 542 from pdb import set_trace;set_trace() 443 543 return 444 data = {}445 544 if mt == 'CPS Proxy Folder': 446 545 return 447 #from pdb import set_trace;set_trace()448 546 for field in self.affected_types[pt]: 449 547 if hasattr(self,'get_from_doc_%s' % field):
Note: See TracChangeset for help on using the changeset viewer.