Index: /WAeUP_SRP/base/skins/waeup_student/search_students.py
===================================================================
--- /WAeUP_SRP/base/skins/waeup_student/search_students.py	(revision 3021)
+++ /WAeUP_SRP/base/skins/waeup_student/search_students.py	(revision 3022)
@@ -41,4 +41,5 @@
 except:
     aq_portal = context.portal_catalog_real.evalAdvancedQuery
+students_catalog = context.students_catalog
 aq_students = context.students_catalog.evalAdvancedQuery
 
@@ -189,4 +190,5 @@
 review_set = []
 search_set = []
+query = None
 if len(term) > 0:
     if what == "student_id":
@@ -201,17 +203,23 @@
                              )
     elif what == "department":
-        res = context.students_catalog(department=term.strip())
+        query = Eq('department', term.strip())
         logger.info('%s searches for student in department %s' % (member,term))
-        search_set = [r.id for r in res]
+        # res = context.students_catalog(department=term.strip())
+        # logger.info('%s searches for student in department %s' % (member,term))
+        # search_set = [r.id for r in res]
     elif what == "matric_no":
-        res = context.students_catalog(matric_no=term.strip())
+        query = Eq('matric_no', term.strip())
         logger.info('%s searches for student with matric_no %s' % (member,term))
-        search_set = [r.id for r in res]
+        # res = context.students_catalog(matric_no=term.strip())
+        # logger.info('%s searches for student with matric_no %s' % (member,term))
+        # search_set = [r.id for r in res]
     elif what == "jamb_reg_no":
         st_l = "%s" % term.strip().lower()
         st_u = "%s" % term.strip().upper()
-        res = aq_students(In('jamb_reg_no',(st_l,st_u)))
+        query = In('jamb_reg_no',(st_l,st_u))
         logger.info('%s searches for student with jamb_reg_no %s' % (member,term))
-        search_set = [r.id for r in res]
+        # res = aq_students(In('jamb_reg_no',(st_l,st_u)))
+        # logger.info('%s searches for student with jamb_reg_no %s' % (member,term))
+        # search_set = [r.id for r in res]
     elif what == "name":
         if len(term) < 4:
@@ -221,12 +229,18 @@
                                                 allowed = allowed,
                                                )
-        pt = ('StudentPersonal')
-        query = In('portal_type',pt) & Eq('SearchableText',"%s*" % term.strip())
+        # pt = ('StudentPersonal')
+        # query = In('portal_type',pt) & Eq('SearchableText',"%s*" % term.strip())
+        # logger.info('%s searches for student with name %s' % (member,term))
+        # res = aq_portal(query)
+        # if res:
+        #     for r in res:
+        #         pl = r.getPath().split('/')
+        #         search_set.append(pl[pl.index('students') + 1])
+        query = Eq('name',"%s*" % term.strip())
         logger.info('%s searches for student with name %s' % (member,term))
-        res = aq_portal(query)
-        if res:
-            for r in res:
-                pl = r.getPath().split('/')
-                search_set.append(pl[pl.index('students') + 1])
+        # res = aq_students(query)
+        # if res:
+        #     for r in res:
+        #         search_set += r.id,
 
 if only_review or with_review or co_view:
@@ -234,7 +248,9 @@
     #review_res = aq_portal(query)
     #review_res = context.portal_catalog(review_state = state)
-
-    query = Eq('review_state',state)
-    review_res = aq_students(query)
+    if query is not None:
+        query = Eq('review_state',state) & query
+    else:
+        query = Eq('review_state',state)
+    #review_res = aq_students(query)
     logger.info('%s searches for students in review_state %s' % (member,state))
 
@@ -242,7 +258,10 @@
     only_review = False
     with_review = True
-    query = In('faculty',faculties) | In('department',departments)
-    res = aq_students(query)
-    search_set = [r.id for r in res]
+    if query is not None:
+        query = query & In('faculty',faculties) | In('department',departments)
+    else:
+        query = In('faculty',faculties) | In('department',departments)
+    # res = aq_students(query)
+    # search_set.extend([r.id for r in res])
 elif ca_view:
     only_review = False
@@ -250,35 +269,55 @@
     courses = [cl.split('/')[0] for cl in certificate_levels]
     levels = [cl.split('/')[1] for cl in certificate_levels]
-    query = In('course',courses) & In('level',levels)
-    res = aq_students(query)
-    search_set = [r.id for r in res]
-if review_res:
-    review_set = [r.id for r in review_res]
-
-#from Products.zdb import set_trace;set_trace()
-
-if only_review:
-    all = review_set
-elif with_review:
-    all = []
-    for i in search_set:
-        if i in review_set:
-            all.append(i)
-else:
-    all = search_set
-
-items = all[:500]
+    if query is not None:
+        query = query & In('course',courses) & In('level',levels)
+    # res = aq_students(query)
+    # search_set.extend([r.id for r in res])
+
+# if review_res:
+    # review_set = [r.id for r in review_res]
+
+# if only_review:
+    # all = review_set
+# elif with_review:
+    # all = []
+    # for i in search_set:
+    #     if i in review_set:
+    #         all.append(i)
+# else:
+    # all = search_set
+    
+# res = aq_students(query)
+# all = [r.id for r in res]
+
+# items = all[:500]
+# students = []
+# if items:
+#     for item in items:
+#         students_catalog = context.students_catalog
+#         record = students_catalog(id = item)
+#         if record:
+#             record = record[0]
+#         else:
+#             return item+' not found in students_catalog'
+#         info = {}
+#         for field in students_catalog.schema() + students_catalog.indexes():
+#             info[field] = getattr(record, field)
+#         else:
+#             students.append(info)
+#     return context.search_students_form(rendered = rend,
+#                              psm = "",
+#                              info = user_info,
+#                              students = students,
+#                              allowed = allowed,
+#                              co_view = co_view,
+#                              ca_view = ca_view
+#                              )
+student_records = aq_students(query)
 students = []
-if items:
-    for item in items:
-        stcat = context.students_catalog
-        record = stcat(id = item)
-        if record:
-            record = record[0]
-        else:
-            return item+' not found in students_catalog'
+if student_records:
+    for student_record in student_records:
         info = {}
-        for field in stcat.schema() + stcat.indexes():
-            info[field] = getattr(record, field)
+        for field in students_catalog.schema() + students_catalog.indexes():
+            info[field] = getattr(student_record, field)
         else:
             students.append(info)
Index: /WAeUP_SRP/uniben/waeup_custom/search_students_form.pt
===================================================================
--- /WAeUP_SRP/uniben/waeup_custom/search_students_form.pt	(revision 3021)
+++ /WAeUP_SRP/uniben/waeup_custom/search_students_form.pt	(revision 3022)
@@ -1,25 +1,23 @@
 <metal:body use-macro="here/main_template/macros/master">
-    <metal:main fill-slot="main"
-            tal:define="rendered options/rendered;
-            portal_status_message options/psm;
-            students options/students;
-            info options/info|nothing;
-            is_so context/isSectionOfficer;
-            allowed options/allowed|nothing;"
-            >
-      <span tal:condition="not: allowed">
-        <span tal:content="here/illegal_view" />
-      </span>
-      <span tal:condition="allowed" tal:omit-tag="">
-      
+  <metal:main fill-slot="main"
+              tal:define="rendered options/rendered;
+              portal_status_message options/psm;
+              students options/students;
+              info options/info|nothing;
+              is_so context/isSectionOfficer;
+              allowed options/allowed|nothing;"
+              >
+    <span tal:condition="not: allowed">
+      <span tal:content="here/illegal_view" />
+    </span>
+    <span tal:condition="allowed" tal:omit-tag="">
       <strong>
-      <nobr><a href="statistics_new_view">New Student Statistics</a>
-      &nbsp;&nbsp;&nbsp;&nbsp;</nobr>
-      <nobr><a href="statistics_ret_view">Returning Student Statistics</a>
-      &nbsp;&nbsp;&nbsp;&nbsp;</nobr>
-      <nobr><a href="statistics_simple_view">Basic Student Statistics</a>
-      &nbsp;&nbsp;&nbsp;&nbsp;</nobr>      
-  
-      <span tal:condition="is_so">
+        <nobr><a href="statistics_new_view">New Student Statistics</a>
+        &nbsp;&nbsp;&nbsp;&nbsp;</nobr>
+        <nobr><a href="statistics_ret_view">Returning Student Statistics</a>
+        &nbsp;&nbsp;&nbsp;&nbsp;</nobr>
+        <nobr><a href="statistics_simple_view">Basic Student Statistics</a>
+        &nbsp;&nbsp;&nbsp;&nbsp;</nobr>      
+        <span tal:condition="is_so">
           <nobr><a href="apply_admission_manage">Application Process</a>
           &nbsp;&nbsp;&nbsp;&nbsp;</nobr>      
@@ -28,117 +26,107 @@
           <nobr><a href="add_student">Add Student Record</a>        
           &nbsp;&nbsp;&nbsp;&nbsp;</nobr>
-          <nobr><a href="deactivate_students">Deactivate Student Record(s)</a>           
+          <nobr><a href="deactivate_students">Deactivate Student Record(s)</a></nobr>
+        </span>
+      </strong>
+      <h3> Search Student Section</h3><br />
+      You are logged in as member <span tal:replace="info/member|nothing" /> 
+      <span tal:condition="info/faculties|nothing" tal:omit-tag="">
+        who is ClearanceOfficer for Faculty 
+        <span tal:repeat="faculty info/faculties" tal:content="faculty" />
       </span>
-      </strong>
-    
-              
-        <h3> Search Student Section</h3><br />
-          You are logged in as member <span tal:replace="info/member|nothing" /> 
-          <span tal:condition="info/faculties|nothing" tal:omit-tag="">
-            who is ClearanceOfficer for Faculty 
-            <span tal:repeat="faculty info/faculties" tal:content="faculty" />
-          </span>
-          <span tal:condition="info/departments|nothing" tal:omit-tag="">
-            and <span tal:repeat="department info/departments|nothing" tal:content="department"/></span>.
-          <br /><br />
-        <span tal:replace="structure rendered" />
-        <span tal:condition="students">
-          <span
-              tal:define="items students;
-              columns python:3;
-              items_per_page python:40;
-              max_items python:300;
-              zoom python:0;
-              batches_all python:here.getBatchList(items,columns, items_per_page,zoom,max_items=400);
-              batches python:batches_all[0];
-              batch_info python:batches_all[1];
-              zoomed python:batches_all[2];
-              mq nocall:modules/ZTUtils/make_query;"
-              tal:omit-tag=""
+      <span tal:condition="info/departments|nothing" tal:omit-tag="">
+        and <span tal:repeat="department info/departments|nothing" tal:content="department"/></span>.
+      <br /><br />
+      <span tal:replace="structure rendered" />
+      <metal:block use-macro="here/generic_lib_portal_message/macros/portal_message" />
+      <span tal:condition="students">
+        <span tal:define="items students;
+        columns python:3;
+        items_per_page python:40;
+        max_items python:300;
+        zoom python:0;
+        batches_all python:here.getBatchList(items,columns, items_per_page,zoom,max_items=400);
+        batches python:batches_all[0];
+        batch_info python:batches_all[1];
+        zoomed python:batches_all[2];
+        mq nocall:modules/ZTUtils/make_query;"
+        tal:omit-tag="">
+          <tal:block tal:condition="python: items and batch_info and batch_info['nb_pages'] > 1">
+            <div class="batchLayout" i18n:translate="">
+              Objects:<strong><tal:block replace="batch_info/start"
+                                         i18n:name="batch_start" /> - <tal:block replace="batch_info/limit"
+                                                                                 i18n:name="batch_limit" />
+              </strong> of <tal:block replace="batch_info/length" i18n:name="batch_length" />
+            </div>
+            <br />
+          </tal:block>
+          <table class="contentListing" width="100%">
+            <span tal:repeat="rows batches" tal:omit-tag="">
+              <span tal:repeat="student rows">
+                <tr tal:condition="student" 
+                    tal:attributes="class python:test(repeat['student'].even(), 'even ajaxtd', 'odd ajaxtd')">
+                  <td><a href="id" tal:attributes="href string:${context/portal_url}/campus/students/${student/id}"
+                         tal:content="student/id"></a></td>    
+                  <td>
+                    <span tal:replace="student/name" />
+                  </td>    
+                  <td><span tal:replace="student/matric_no" /></td>   
+                  <td><span tal:replace="student/jamb_reg_no" /></td>
+                  <td tal:condition="options/co_view|nothing">
+                    <a href="id" 
+                       tal:attributes="href string:${context/portal_url}/campus/students/${student/id}/clearance/external_clearance_edit_form"
+                       target="edit"
+                       onclick="javascript:window.open('','edit','width=600, height=700, directories=no, toolbar=no, location=no, menubar=no, scrollbars=yes, status=no, resizable=no, dependent=no')"
+                       >[view and change state]</a></td>
+                  <td tal:condition="options/ca_view|nothing">
+                    <a href="id" 
+                       tal:attributes="href string:${context/portal_url}/campus/students/${student/id}/study_course/study_course/${student/level}/external_study_level_view"
+                       target="edit"
+                       onclick="javascript:window.open('','edit','width=600, height=700, directories=no, toolbar=no, location=no, menubar=no, scrollbars=yes, status=no, resizable=no, dependent=no')"
+                       >[view and validate course list]</a></td>
+                </tr>
+              </span>
+            </span>
+          </table>
+          <tal:block condition="python:batch_info and batch_info['nb_pages'] > 1">
+            <div class="pageNavigationLayout">
+              <a tal:define="previous batch_info/previous"
+                 tal:condition="python:previous is not None"
+                 tal:attributes="href python:'%s?%s'%(request['URL'],
+                 mq(request.form, b_start=0))"
+                 >
+              (&lt;&lt;)</a>
+              <a tal:define="previous batch_info/previous"
+                 tal:condition="python:previous is not None"
+                 tal:attributes="href python:'%s?%s'%(request['URL'],
+                 mq(request.form, b_start=previous))"
+                 i18n:translate="batch_previous">Previous</a>
+              <tal:block repeat="page batch_info/pages">
+                <tal:block condition="python:page != batch_info['start'] - 1">
+                  <a tal:attributes="href python:'%s?%s'%(request['URL'],
+                  mq(request.form, b_start=page))"
+                  tal:content="repeat/page/number">1</a>&nbsp;
+                </tal:block>
+                <tal:block condition="python:page == batch_info['start'] - 1">
+                  <span tal:content="string:${repeat/page/number}" />&nbsp;
+                </tal:block>
+              </tal:block>
+              <a tal:define="next batch_info/next"
+                 tal:condition="python:next is not None"
+                 tal:attributes="href python:'%s?%s'%(request['URL'],
+                 mq(request.form, b_start=next))"
+                 i18n:translate="batch_next">Next</a>
+              <a tal:define="next batch_info/next;
+              last_page python:batch_info['pages'][-1]"
+              tal:condition="python:next is not None"
+              tal:attributes="href python:'%s?%s'%(request['URL'],
+              mq(request.form, b_start=last_page))"
               >
-            <tal:block tal:condition="python: items and batch_info and batch_info['nb_pages'] > 1">
-              <div class="batchLayout">
-                <span i18n:translate="">
-                  Objects: 
-                  <strong>
-                    <tal:block replace="batch_info/start"
-                               i18n:name="batch_start" /> - <tal:block replace="batch_info/limit"
-                                                                       i18n:name="batch_limit" />
-                  </strong>
-                  of <tal:block replace="batch_info/length"
-                                i18n:name="batch_length" />
-                </span>
-              </div>
-              <br />
-            </tal:block>
-            <table class="contentListing" width="100%">
-              <span tal:repeat="rows batches" tal:omit-tag="">
-                <span tal:repeat="student rows">
-                  <tr tal:condition="student" 
-                      tal:attributes="class python:test(repeat['student'].even(), 'even ajaxtd', 'odd ajaxtd')">
-                    <td><a href="id" tal:attributes="href string:${context/portal_url}/campus/students/${student/id}"
-                           tal:content="student/id"></a></td>    
-                    <td>
-                      <span tal:replace="student/name" />
-                    </td>    
-                    <td><span tal:replace="student/matric_no" /></td>   
-                    <td><span tal:replace="student/jamb_reg_no" /></td>
-                    <td tal:condition="options/co_view|nothing">
-                      <a href="id" 
-                         tal:attributes="href string:${context/portal_url}/campus/students/${student/id}/clearance/external_clearance_edit_form"
-                         target="edit"
-                         onclick="javascript:window.open('','edit','width=600, height=700, directories=no, toolbar=no, location=no, menubar=no, scrollbars=yes, status=no, resizable=no, dependent=no')"
-                         >[view and change state]</a></td>
-                    <td tal:condition="options/ca_view|nothing">
-                      <a href="id" 
-                         tal:attributes="href string:${context/portal_url}/campus/students/${student/id}/study_course/study_course/${student/level}/external_study_level_view"
-                         target="edit"
-                         onclick="javascript:window.open('','edit','width=600, height=700, directories=no, toolbar=no, location=no, menubar=no, scrollbars=yes, status=no, resizable=no, dependent=no')"
-                         >[view and validate course list]</a></td>
-                  </tr>
-                </span>
-              </span>
-            </table>
-            <tal:block condition="python:batch_info and batch_info['nb_pages'] > 1">
-              <div class="pageNavigationLayout">
-                <a tal:define="previous batch_info/previous"
-                   tal:condition="python:previous is not None"
-                   tal:attributes="href python:'%s?%s'%(request['URL'],
-                   mq(request.form, b_start=0))"
-                   >
-                (&lt;&lt;)</a>
-                <a tal:define="previous batch_info/previous"
-                   tal:condition="python:previous is not None"
-                   tal:attributes="href python:'%s?%s'%(request['URL'],
-                   mq(request.form, b_start=previous))"
-                   i18n:translate="batch_previous">Previous</a>
-                <tal:block repeat="page batch_info/pages">
-                  <tal:block condition="python:page != batch_info['start'] - 1">
-                    <a tal:attributes="href python:'%s?%s'%(request['URL'],
-                    mq(request.form, b_start=page))"
-                    tal:content="repeat/page/number">1</a>&nbsp;
-                  </tal:block>
-                  <tal:block condition="python:page == batch_info['start'] - 1">
-                    <span tal:content="string:${repeat/page/number}" />&nbsp;
-                  </tal:block>
-                </tal:block>
-                <a tal:define="next batch_info/next"
-                   tal:condition="python:next is not None"
-                   tal:attributes="href python:'%s?%s'%(request['URL'],
-                   mq(request.form, b_start=next))"
-                   i18n:translate="batch_next">Next</a>
-                <a tal:define="next batch_info/next;
-                last_page python:batch_info['pages'][-1]"
-                tal:condition="python:next is not None"
-                tal:attributes="href python:'%s?%s'%(request['URL'],
-                mq(request.form, b_start=last_page))"
-                >
-                (&gt;&gt;)</a>
-              </div>
-            </tal:block>
-          </span>
+              (&gt;&gt;)</a>
+            </div>
+          </tal:block>
         </span>
       </span>
-    </metal:main>
+    </span>
+  </metal:main>
 </metal:body>
-  
