Index: main/waeup.sirp/trunk/src/waeup/sirp/students/catalog.py
===================================================================
--- main/waeup.sirp/trunk/src/waeup/sirp/students/catalog.py	(revision 6785)
+++ main/waeup.sirp/trunk/src/waeup/sirp/students/catalog.py	(revision 6786)
@@ -5,5 +5,6 @@
 from hurry.query import Eq, Text
 from hurry.query.query import Query
-from zope.index.text.parsetree import ParseError
+from zope.catalog.interfaces import ICatalog
+from zope.component import queryUtility
 from waeup.sirp.interfaces import IUniversity, IQueryResultItem
 from waeup.sirp.students.interfaces import IStudent
@@ -26,5 +27,5 @@
 
     title = u'Student Query Item'
-    description = u'Some students found in a search'
+    description = u'Some student found in a search'
 
     def __init__(self, context, view):
@@ -39,7 +40,4 @@
 def search(query=None, searchtype=None, view=None):
     hitlist = []
-    #if not query:
-    #    view.flash('Empty search string.')
-    #    return
     if searchtype in ('name',):
         results = Query().searchResults(
@@ -48,6 +46,4 @@
         # Temporary solution to display all students added
         if query == '*':
-            from zope.component import queryUtility
-            from zope.catalog.interfaces import ICatalog
             cat = queryUtility(ICatalog, name='students_catalog')
             results = cat.searchResults(student_id=(None, None))
@@ -58,2 +54,26 @@
         hitlist.append(StudentQueryResultItem(result, view=view))
     return hitlist
+
+class SimpleFieldSearch(object):
+    """A programmatic (no UI required) search.
+
+    Looks up a given field attribute of the students catalog for a
+    single value. So normally you would call an instance of this
+    search like this:
+
+      >>> SimpleFieldSearch()(reg_number='somevalue')
+
+    """
+    catalog_name = 'students_catalog'
+    def __call__(self, **kw):
+        """Search students catalog programmatically.
+        """
+        if len(kw) != 1:
+            raise ValueError('must give exactly one index name to search')
+        cat = queryUtility(ICatalog, name=self.catalog_name)
+        index_name, query_term = kw.items()[0]
+        results = cat.searchResults(index_name=(query_term, query_term))
+        return results
+
+#: an instance of `SimpleFieldSearch` looking up students catalog.
+simple_search = SimpleFieldSearch()
