Index: WAeUP_SRP/trunk/PatchCatalogToolSearchResults.py
===================================================================
--- WAeUP_SRP/trunk/PatchCatalogToolSearchResults.py	(revision 1845)
+++ WAeUP_SRP/trunk/PatchCatalogToolSearchResults.py	(revision 1845)
@@ -0,0 +1,60 @@
+from Products.CMFCore import CatalogTool
+from Products.CMFCore.utils import _getAuthenticatedUser
+from Products.ZCatalog.ZCatalog import ZCatalog
+# searchResults has inherited security assertions.
+def searchResults(self, REQUEST=None, **kw):
+    """
+        Calls ZCatalog.searchResults with extra arguments that
+        limit the results to what the user is allowed to see.
+    """
+    user = _getAuthenticatedUser(self)
+    kw[ 'allowedRolesAndUsers' ] = self._listAllowedRolesAndUsers( user )
+
+    if not _checkPermission( AccessInactivePortalContent, self ):
+        now = DateTime()
+
+        self._convertQuery(kw)
+
+        # Intersect query restrictions with those implicit to the tool
+        # for k in 'effective', 'expires':
+        #     if kw.has_key(k):
+        #         range = kw[k]['range'] or ''
+        #         query = kw[k]['query']
+        #         if not isinstance(query, (tuple, list)):
+        #             query = (query,)
+        #     else:
+        #         range = ''
+        #         query = None
+        #     if range.find('min') > -1:
+        #         lo = min(query)
+        #     else:
+        #         lo = None
+        #     if range.find('max') > -1:
+        #         hi = max(query)
+        #     else:
+        #         hi = None
+        #     if k == 'effective':
+        #         if hi is None or hi > now:
+        #             hi = now
+        #         if lo is not None and hi < lo:
+        #             return ()
+        #     else: # 'expires':
+        #         if lo is None or lo < now:
+        #             lo = now
+        #         if hi is not None and hi < lo:
+        #             return ()
+        #     # Rebuild a query
+        #     if lo is None:
+        #         query = hi
+        #         range = 'max'
+        #     elif hi is None:
+        #         query = lo
+        #         range = 'min'
+        #     else:
+        #         query = (lo, hi)
+        #         range = 'min:max'
+        #     kw[k] = {'query': query, 'range': range}
+
+    return ZCatalog.searchResults(self, REQUEST, **kw)
+
+CatalogTool.searchResults = searchResults
Index: WAeUP_SRP/trunk/WAeUPTables.py
===================================================================
--- WAeUP_SRP/trunk/WAeUPTables.py	(revision 1844)
+++ WAeUP_SRP/trunk/WAeUPTables.py	(revision 1845)
@@ -32,4 +32,5 @@
 p_home = Globals.package_home(globals())
 i_home = Globals.INSTANCE_HOME
+from Products.CMFCore.CatalogTool import CatalogTool
 from Products.AdvancedQuery import Eq, Between, Le,In
 
@@ -45,4 +46,8 @@
     return ob
 
+class RealCatalogTool(CatalogTool):
+    meta_type = 'Catalog Tool Real'
+    name = id = "portal_catalog_real"
+    
 
 class WAeUPTable(ZCatalog): ###(
Index: WAeUP_SRP/trunk/__init__.py
===================================================================
--- WAeUP_SRP/trunk/__init__.py	(revision 1844)
+++ WAeUP_SRP/trunk/__init__.py	(revision 1845)
@@ -12,4 +12,5 @@
 
 import PatchCPSWorkflowWorkflowDefinition
+#import PatchCatalogToolSearchResults
 import PatchCatalogToolXMLAdapter
 import PatchCPSSchemasAttributeStorageAdapter
@@ -26,5 +27,5 @@
 import PatchCPSDefaultImportExport
 import PatchRenderActionIcon
-import PatchZODBConnectionOpen
+#import PatchZODBConnectionOpen
 import Products.WAeUP_SRP.WAeUPPermissions
 import WAeUPTool
Index: WAeUP_SRP/trunk/profiles/default/portal_catalog_real.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/portal_catalog_real.xml	(revision 1845)
+++ WAeUP_SRP/trunk/profiles/default/portal_catalog_real.xml	(revision 1845)
@@ -0,0 +1,150 @@
+<?xml version="1.0"?>
+<object name="portal_catalog_real" meta_type="CMF Catalog">
+ <property name="title"></property>
+ <object name="cps_defaut_lexicon" meta_type="ZCTextIndex Lexicon">
+  <element name="Whitespace splitter" group="Word Splitter"/>
+  <element name="Case Normalizer" group="Case Normalizer"/>
+ </object>
+ <object name="htmltext_lexicon" meta_type="ZCTextIndex Lexicon">
+  <element name="HTML aware splitter" group="Word Splitter"/>
+  <element name="Case Normalizer" group="Case Normalizer"/>
+  <element name="Remove listed stop words only" group="Stop Words"/>
+ </object>
+ <object name="plaintext_lexicon" meta_type="ZCTextIndex Lexicon">
+  <element name="Whitespace splitter" group="Word Splitter"/>
+  <element name="Case Normalizer" group="Case Normalizer"/>
+  <element name="Remove listed stop words only" group="Stop Words"/>
+ </object>
+ <index name="Creator" meta_type="FieldIndex">
+  <indexed_attr value="Creator"/>
+ </index>
+ <index name="Date" meta_type="DateIndex">
+  <property name="index_naive_time_as_local">True</property>
+ </index>
+ <index name="Description" meta_type="ZCTextIndex">
+  <indexed_attr value="Description"/>
+  <extra name="index_type" value="Okapi BM25 Rank"/>
+  <extra name="lexicon_id" value="plaintext_lexicon"/>
+ </index>
+ <index name="Language" meta_type="FieldIndex">
+  <indexed_attr value="Language"/>
+ </index>
+ <index name="SearchableText" meta_type="ZCTextIndex">
+  <indexed_attr value="SearchableText"/>
+  <extra name="index_type" value="Okapi BM25 Rank"/>
+  <extra name="lexicon_id" value="htmltext_lexicon"/>
+ </index>
+ <index name="Subject" meta_type="KeywordIndex">
+  <indexed_attr value="Subject"/>
+ </index>
+ <index name="Title" meta_type="FieldIndex">
+  <indexed_attr value="Title"/>
+ </index>
+ <index name="Type" meta_type="FieldIndex">
+  <indexed_attr value="Type"/>
+ </index>
+ <index name="ZCTitle" meta_type="ZCTextIndex">
+  <indexed_attr value="Title"/>
+  <extra name="index_type" value="Okapi BM25 Rank"/>
+  <extra name="lexicon_id" value="cps_defaut_lexicon"/>
+ </index>
+ <index name="allowedRolesAndUsers" meta_type="KeywordIndex">
+  <indexed_attr value="allowedRolesAndUsers"/>
+ </index>
+ <index name="container_path" meta_type="FieldIndex">
+  <indexed_attr value="container_path"/>
+ </index>
+ <index name="cps_filter_sets" meta_type="TopicIndex">
+  <filtered_set name="default_languages" meta_type="PythonFilteredSet"
+     expression="not hasattr(o, 'isDefaultLanguage') or o.isDefaultLanguage()"/>
+  <filtered_set name="leaves" meta_type="PythonFilteredSet"
+     expression="not o.isCPSFolderish()"/>
+  <filtered_set name="nodes" meta_type="PythonFilteredSet"
+     expression="o.isCPSFolderish()"/>
+  <filtered_set name="searchable" meta_type="PythonFilteredSet"
+     expression="not filter(lambda s: s.startswith('portal_') or s and s[0] in ('.', '_'), o.getPhysicalPath())"/>
+ </index>
+ <index name="created" meta_type="DateIndex">
+  <property name="index_naive_time_as_local">True</property>
+ </index>
+ <index name="effective" meta_type="DateIndex">
+  <property name="index_naive_time_as_local">True</property>
+ </index>
+ <index name="end" meta_type="DateIndex">
+  <property name="index_naive_time_as_local">True</property>
+ </index>
+ <index name="expires" meta_type="DateIndex">
+  <property name="index_naive_time_as_local">True</property>
+ </index>
+ <index name="getId" meta_type="FieldIndex">
+  <indexed_attr value="getId"/>
+ </index>
+ <index name="id" meta_type="FieldIndex">
+  <indexed_attr value="id"/>
+ </index>
+ <index name="in_reply_to" meta_type="FieldIndex">
+  <indexed_attr value="in_reply_to"/>
+ </index>
+ <index name="listCreators" meta_type="KeywordIndex">
+  <indexed_attr value="listCreators"/>
+ </index>
+ <index name="localUsersWithRoles" meta_type="KeywordIndex">
+  <indexed_attr value="localUsersWithRoles"/>
+ </index>
+ <index name="meta_type" meta_type="FieldIndex">
+  <indexed_attr value="meta_type"/>
+ </index>
+ <index name="modified" meta_type="DateIndex">
+  <property name="index_naive_time_as_local">True</property>
+ </index>
+ <index name="path" meta_type="PathIndex"/>
+ <index name="portal_type" meta_type="FieldIndex">
+  <indexed_attr value="portal_type"/>
+ </index>
+ <index name="position_in_container" meta_type="FieldIndex">
+  <indexed_attr value="position_in_container"/>
+ </index>
+ <index name="relative_path" meta_type="FieldIndex">
+  <indexed_attr value="relative_path"/>
+ </index>
+ <index name="relative_path_depth" meta_type="FieldIndex">
+  <indexed_attr value="relative_path_depth"/>
+ </index>
+ <index name="review_state" meta_type="FieldIndex">
+  <indexed_attr value="review_state"/>
+ </index>
+ <index name="start" meta_type="DateIndex">
+  <property name="index_naive_time_as_local">True</property>
+ </index>
+ <index name="time" meta_type="DateIndex">
+  <property name="index_naive_time_as_local">True</property>
+ </index>
+ <column value="Contributors"/>
+ <column value="CreationDate"/>
+ <column value="Creator"/>
+ <column value="Date"/>
+ <column value="Description"/>
+ <column value="EffectiveDate"/>
+ <column value="ExpirationDate"/>
+ <column value="Language"/>
+ <column value="ModificationDate"/>
+ <column value="Subject"/>
+ <column value="Title"/>
+ <column value="Type"/>
+ <column value="created"/>
+ <column value="effective"/>
+ <column value="end"/>
+ <column value="expires"/>
+ <column value="getIcon"/>
+ <column value="getId"/>
+ <column value="getRevision"/>
+ <column value="id"/>
+ <column value="listCreators"/>
+ <column value="modified"/>
+ <column value="portal_type"/>
+ <column value="position_in_container"/>
+ <column value="relative_path"/>
+ <column value="review_state"/>
+ <column value="start"/>
+ <column value="time"/>
+</object>
Index: WAeUP_SRP/trunk/profiles/default/toolset.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/toolset.xml	(revision 1844)
+++ WAeUP_SRP/trunk/profiles/default/toolset.xml	(revision 1845)
@@ -1,4 +1,6 @@
 <?xml version="1.0"?>
 <tool-setup>
+ <required tool_id="portal_catalog_real"
+           class="Products.WAeUP_SRP.WAeUPTables.RealCatalogTool"/>
  <required tool_id="portal_accommodation"
            class="Products.WAeUP_SRP.WAeUPTables.AccommodationTable"/>
Index: WAeUP_SRP/trunk/skins/waeup_directory/search_members.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_directory/search_members.py	(revision 1844)
+++ WAeUP_SRP/trunk/skins/waeup_directory/search_members.py	(revision 1845)
@@ -11,9 +11,10 @@
 
 from Products.CPSDirectory.BaseDirectory import SearchSizeLimitExceeded
+from Products.AdvancedQuery import Eq, Between, Le,In
+aq_portal = context.portal_catalog.evalAdvancedQuery
 try:
-    from Products.AdvancedQuery import Eq, Between, Le,In
-    evalAdvancedQuery = context.portal_catalog.evalAdvancedQuery
+    aq_portal = context.portal_catalog.evalAdvancedQuery
 except:
-    evalAdvancedQuery = None
+    aq_portal = context.portal_catalog_real.evalAdvancedQuery
 
 datamodel = datastructure.getDataModel()
@@ -80,5 +81,5 @@
     query = In('portal_type',('Faculty','Department')) &\
             In('localUsersWithRoles',('user:%s' % user_id,))
-    res = evalAdvancedQuery(query)
+    res = aq_portal(query)
     facs = []
     roles = []
Index: WAeUP_SRP/trunk/skins/waeup_epayment/check_online_payments.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_epayment/check_online_payments.py	(revision 1844)
+++ WAeUP_SRP/trunk/skins/waeup_epayment/check_online_payments.py	(revision 1845)
@@ -36,13 +36,13 @@
     response.setHeader('Content-type','text/html; charset=ISO-8859-15')
     response.write("%s<br>\n" % s)
+from Products.AdvancedQuery import Eq, Between, Le,In
 try:
-    from Products.AdvancedQuery import Eq, Between, Le,In
     aq_portal = context.portal_catalog.evalAdvancedQuery
-    aq_students = context.students_catalog.evalAdvancedQuery
 except:
-    aq_portal = None
+    aq_portal = context.portal_catalog_real.evalAdvancedQuery
+aq_students = context.students_catalog.evalAdvancedQuery
 
 query1 = Eq('portal_type','Payment')
-query2 = Eq('SearchableText',"Approved Successful")	 	
+query2 = Eq('SearchableText',"Approved Successful")             
 online_payments = aq_portal(query1 & query2)
 set_trace()
Index: WAeUP_SRP/trunk/skins/waeup_epayment/getPaymentsFolderInfo.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_epayment/getPaymentsFolderInfo.py	(revision 1844)
+++ WAeUP_SRP/trunk/skins/waeup_epayment/getPaymentsFolderInfo.py	(revision 1845)
@@ -16,4 +16,9 @@
 if mtool.isAnonymousUser():
     return None
+try:
+    from Products.zdb import set_trace
+except:
+    def set_trace():
+        pass
 
 
@@ -32,5 +37,5 @@
 request = context.REQUEST
 students = context.portal_url.getPortalObject().campus.students
-
+#set_trace()
 student_id = context.getStudentId()
 if student_id is None:
Index: WAeUP_SRP/trunk/skins/waeup_student/add_course_result.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/add_course_result.py	(revision 1844)
+++ WAeUP_SRP/trunk/skins/waeup_student/add_course_result.py	(revision 1845)
@@ -25,5 +25,8 @@
 course_cat = context.courses_catalog
 from Products.AdvancedQuery import Eq, Between, Le,In
-aq_portal = context.portal_catalog.evalAdvancedQuery
+try:
+    aq_portal = context.portal_catalog.evalAdvancedQuery
+except:
+    aq_portal = context.portal_catalog_real.evalAdvancedQuery
 course_id = request.get('course_id')
 
Index: WAeUP_SRP/trunk/skins/waeup_student/create_level.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/create_level.py	(revision 1844)
+++ WAeUP_SRP/trunk/skins/waeup_student/create_level.py	(revision 1845)
@@ -13,5 +13,8 @@
         pass
 from Products.AdvancedQuery import Eq, Between, Le,In
-aq_portal = context.portal_catalog.evalAdvancedQuery
+try:
+    aq_portal = context.portal_catalog.evalAdvancedQuery
+except:
+    aq_portal = context.portal_catalog_real.evalAdvancedQuery
 aq_courses = context.courses_catalog.evalAdvancedQuery
 
@@ -37,4 +40,5 @@
     logger.info('%s tried to add already existing level %s' % (student.id,current_level))
     return
+logger.info('%s started to create level %s' % (student.id,current_level))
 
 ##if in_progress in ('not started','started'):
@@ -53,5 +57,4 @@
 else:
     context.invokeFactory('StudentStudyLevel',"%s" % current_level)
-    logger.info('%s started to create level %s' % (student.id,current_level))
     level = getattr(context,"%s" % current_level)
     context.portal_workflow.doActionFor(level,'open')
@@ -76,5 +79,5 @@
         c_res = aq_courses(query)
         if not c_res:
-            logger.info('%s", course %s not found in courses_catalog' % (student.id,co.CosCode))
+            #logger.info('%s", course %s not found in courses_catalog' % (student.id,co.CosCode))
             continue
         course_cat_entry = c_res[0]
@@ -86,7 +89,7 @@
                 score = int(co.Score)
             except:
-                logger.info('%s, course %s has invalid score %s"' % (student.id,
-                                                                    co.CosCode,
-                                                                    co.Score))
+                # logger.info('%s, course %s has invalid score %s"' % (student.id,
+                #                                                     co.CosCode,
+                #                                                     co.Score))
                 continue
             if int(c_res[0].passmark) <= score:
Index: WAeUP_SRP/trunk/skins/waeup_student/getStudentReviewState.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/getStudentReviewState.py	(revision 1844)
+++ WAeUP_SRP/trunk/skins/waeup_student/getStudentReviewState.py	(revision 1845)
@@ -12,9 +12,9 @@
 return the review_state of the Student
 """
+from Products.AdvancedQuery import Eq, Between, Le,In
 try:
-    from Products.AdvancedQuery import Eq, Between, Le,In
     aq_portal = context.portal_catalog.evalAdvancedQuery
 except:
-    aq_portal = None
+    aq_portal = context.portal_catalog_real.evalAdvancedQuery
 if student_id is None:
     student_id = context.getStudentId()
Index: WAeUP_SRP/trunk/skins/waeup_student/getStudyLevelInfo.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/getStudyLevelInfo.py	(revision 1844)
+++ WAeUP_SRP/trunk/skins/waeup_student/getStudyLevelInfo.py	(revision 1845)
@@ -26,5 +26,8 @@
         
 from Products.AdvancedQuery import Eq, Between, Le,In
-aq_portal = context.portal_catalog.evalAdvancedQuery
+try:
+    aq_portal = context.portal_catalog.evalAdvancedQuery
+except:
+    aq_portal = context.portal_catalog_real.evalAdvancedQuery
 request = context.REQUEST
 #session = request.SESSION
Index: WAeUP_SRP/trunk/skins/waeup_student/refresh_level.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/refresh_level.py	(revision 1844)
+++ WAeUP_SRP/trunk/skins/waeup_student/refresh_level.py	(revision 1845)
@@ -19,5 +19,8 @@
         pass
 from Products.AdvancedQuery import Eq, Between, Le,In
-aq_portal = context.portal_catalog.evalAdvancedQuery
+try:
+    aq_portal = context.portal_catalog.evalAdvancedQuery
+except:
+    aq_portal = context.portal_catalog_real.evalAdvancedQuery
 aq_courses = context.courses_catalog.evalAdvancedQuery
 
Index: WAeUP_SRP/trunk/skins/waeup_student/search_students.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/search_students.py	(revision 1844)
+++ WAeUP_SRP/trunk/skins/waeup_student/search_students.py	(revision 1845)
@@ -31,10 +31,10 @@
 if is_anon:
     allowed = False
+from Products.AdvancedQuery import Eq, Between, Le,In
 try:
-    from Products.AdvancedQuery import Eq, Between, Le,In
-    evalAdvancedQuery = context.portal_catalog.evalAdvancedQuery
-    aq_students = context.students_catalog.evalAdvancedQuery
+    aq_portal = context.portal_catalog.evalAdvancedQuery
 except:
-    evalAdvancedQuery = None
+    aq_portal = context.portal_catalog_real.evalAdvancedQuery
+aq_students = context.students_catalog.evalAdvancedQuery
 
 def cmp_id(a,b):
@@ -81,5 +81,5 @@
         query = In('portal_type',('Faculty',)) &\
                  In('localUsersWithRoles', ("user:%s" % member,))
-        res = evalAdvancedQuery(query)
+        res = aq_portal(query)
         logger.info('ClearanceOfficer %s initiated student_search' % member)
         faculties = []
@@ -90,5 +90,5 @@
         query = In('portal_type',('Department',)) &\
                  In('localUsersWithRoles', ("user:%s" % member,))
-        res = evalAdvancedQuery(query)
+        res = aq_portal(query)
         departments = []
         if res:
@@ -107,5 +107,5 @@
         query = In('portal_type',('StudyLevel',)) &\
                  In('localUsersWithRoles', ("user:%s" % member,))
-        res = evalAdvancedQuery(query)
+        res = aq_portal(query)
         logger.info('CourseAdviser %s initiated student_search' % member)
         certificate_level = []
@@ -195,5 +195,5 @@
         query = In('portal_type',pt) & Eq('SearchableText',"%s*" % term.strip())
         logger.info('%s searches for student with name %s' % (member,term))
-        res = evalAdvancedQuery(query)
+        res = aq_portal(query)
         if res:
             for r in res:
@@ -207,5 +207,5 @@
         logger.info('"%s","start 100"' % member)
     query = Eq('review_state',state)
-    review_res = evalAdvancedQuery(query)
+    review_res = aq_portal(query)
 
     logger.info('%s searches for students in review_state %s' % (member,state))
Index: WAeUP_SRP/trunk/skins/waeup_student/student_index.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/student_index.py	(revision 1844)
+++ WAeUP_SRP/trunk/skins/waeup_student/student_index.py	(revision 1845)
@@ -12,6 +12,9 @@
 return the current student_index
 """
-from Products.AdvancedQuery import Eq, Between, Le,In
-evalAdvancedQuery = context.portal_catalog.evalAdvancedQuery
+# from Products.AdvancedQuery import Eq, Between, Le,In
+# try:
+#     aq_portal = context.portal_catalog.evalAdvancedQuery
+# except:
+#     aq_portal = context.portal_catalog_real.evalAdvancedQuery
 
 request = context.REQUEST
