Ignore:
Timestamp:
28 Nov 2007, 09:00:07 (17 years ago)
Author:
joachim
Message:

new search method please test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/skins/waeup_student/getStudentFolderInfo.py

    r2745 r2806  
    2323import logging
    2424logger = logging.getLogger('Skins.getStudentFolderInfo')
     25from Products.AdvancedQuery import Eq, Between, Le,In
     26try:
     27    aq_portal = context.portal_catalog.evalAdvancedQuery
     28except:
     29    aq_portal = context.portal_catalog_real.evalAdvancedQuery
    2530
    2631
     
    4752student_path_root = "%s/campus/students/%s" % (context.portal_url.getPortalPath(),student_id)
    4853student_path = "%s/campus/students/%s" % (context.portal_url(),student_id)
    49 res = context.students_catalog(id = student_id)
    50 if not res:
     54students_folder = context.portal_url.getPortalObject().campus.students
     55# res = context.students_catalog(id = student_id)
     56# if not res:
     57#     return None
     58# student_record = res[0]
     59student_record = context.students_catalog.getRecordByKey(student_id)
     60if student_record is None:
    5161    return None
    52 st_brain = res[0]
     62   
    5363#from Products.zdb import set_trace;set_trace()
    5464for field in context.students_catalog.schema():
    55     info[field] = getattr(st_brain,field)
     65    info[field] = getattr(student_record,field)
    5666
    5767#res = context.portal_catalog(portal_type='Student',id = student_id)
     
    5969#    info['review_state'] = res[0].review_state
    6070
    61 info['review_state'] = context.getStudentReviewState()
     71#info['review_state'] = context.getStudentReviewState()
    6272
    6373info['session'] = False
    64 if st_brain.matric_no:
    65     res = context.results_import(matric_no = st_brain.matric_no)
     74if student_record.matric_no:
     75    res = context.results_import(matric_no = student_record.matric_no)
    6676    if res:
    6777       info['session'] = True
    6878
    69 info['base_info'] = context.getFormattedStudentEntry(st_brain)
     79info['base_info'] = context.getFormattedStudentEntry(student_record)
    7080
    7181info['id'] = student_id
     
    8595#logger.info("before search")
    8696starttime = DateTime.DateTime().timeTime()
    87 sos = context.portal_catalog(container_path=student_path_root)
     97#sos = context.portal_catalog(container_path=student_path_root)
     98# query = Eq('container_path',student_path_root)
     99# sos = aq_portal(query)
     100# logger.info("searchtime %f" % (DateTime.DateTime().timeTime() - starttime))
     101# starttime = DateTime.DateTime().timeTime()
     102# for so in sos:
     103#     row = {}
     104#     row['id'] = so.getId
     105#     row['title'] = so.Title
     106#     url = row['url'] = "%s/%s" % (student_path,so.getId)
     107#     row['type'] = so.portal_type
     108#     review_state = row['review_state'] = so.review_state
     109#     row['is_editable'] = (is_student and review_state == "opened") or is_sectionofficer
     110#     sv_link = s_view_links.get(so.portal_type,None) or "waeup_document_view"
     111#     row['s_view_link'] = "%s/%s" % (url,sv_link)
     112#     se_link = s_edit_links.get(so.portal_type,None)
     113#     row['s_edit_link'] = None
     114#     if se_link:
     115#         row['s_edit_link'] = "%s/%s" % (url,se_link)
     116#     row['display'] = review_state in ('opened','closed','bed_reserved','maintenance_fee_paid',)\
     117#                     and so.portal_type not in  ('StudentPume','StudentAccommodation','PaymentsFolder',) or\
     118#                     so.portal_type == 'StudentStudyCourse'
     119#     items.append(row)
     120starttime = DateTime.DateTime().timeTime()
     121#sos = context.portal_catalog(container_path=student_path_root)
     122student_obj = getattr(students_folder,student_id)
     123subobjects = student_obj.objectValues()
    88124logger.info("searchtime %f" % (DateTime.DateTime().timeTime() - starttime))
    89125starttime = DateTime.DateTime().timeTime()
    90 for so in sos:
     126for subobject in subobjects:
    91127    row = {}
    92     row['id'] = so.getId
    93     row['title'] = so.Title
    94     url = row['url'] = "%s/%s" % (student_path,so.getId)
    95     row['type'] = so.portal_type
    96     review_state = row['review_state'] = so.review_state
     128    row['id'] = subobject.getId()
     129    row['title'] = subobject.Title
     130    url = row['url'] = subobject.absolute_url()
     131    row['type'] = subobject.portal_type
     132    review_state = row['review_state'] = wf.getInfoFor(subobject,'review_state',None)
    97133    row['is_editable'] = (is_student and review_state == "opened") or is_sectionofficer
    98     sv_link = s_view_links.get(so.portal_type,None) or "waeup_document_view"
     134    sv_link = s_view_links.get(subobject.portal_type,None) or "waeup_document_view"
    99135    row['s_view_link'] = "%s/%s" % (url,sv_link)
    100     se_link = s_edit_links.get(so.portal_type,None)
     136    se_link = s_edit_links.get(subobject.portal_type,None)
    101137    row['s_edit_link'] = None
    102138    if se_link:
    103139        row['s_edit_link'] = "%s/%s" % (url,se_link)
    104140    row['display'] = review_state in ('opened','closed','bed_reserved','maintenance_fee_paid',)\
    105                     and so.portal_type not in  ('StudentPume','StudentAccommodation','PaymentsFolder',) or\
    106                     so.portal_type == 'StudentStudyCourse'
     141                    and subobject.portal_type not in  ('StudentPume','StudentAccommodation','PaymentsFolder',) or\
     142                    subobject.portal_type == 'StudentStudyCourse'
    107143    items.append(row)
    108144logger.info("listtime %f" % (DateTime.DateTime().timeTime() - starttime))
Note: See TracChangeset for help on using the changeset viewer.