CVS: tmda-cgi PendList.py, 1.26, 1.27 TODO, 1.23, 1.24 ChangeLog, 1.71, 1.72

Jim Ramsay <[email protected]>
Newsgroups gmane.mail.spam.tmda.cvs
Message-ID <[email protected]>
Update of /cvsroot/tmda/tmda-cgi
In directory sc8-pr-cvs1:/tmp/cvs-serv25903

Modified Files:
	PendList.py TODO ChangeLog 
Log Message:
Added preliminary pendinglist searching - JBR


Index: PendList.py
===================================================================
RCS file: /cvsroot/tmda/tmda-cgi/PendList.py,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- PendList.py	16 Nov 2003 18:42:57 -0000	1.26
+++ PendList.py	4 Dec 2003 17:30:47 -0000	1.27
@@ -172,6 +172,47 @@
   except Errors.QueueError:
     Msgs = []
 
+  # Search the Pending List:
+  #
+  #  If the from has the keys searchPattern and search
+  #  we can search.
+  #
+  #  - searchPattern: a basic RE pattern which contains exactly one "%s" 
+  #    where the user's search string goes.
+  #  - search: The user's search string for incorporation into the searchPattern
+  #
+  # For an example, check out the source for the Pending List in the theme 
+  # 'Blue'
+  #
+  Searching = 0
+  if Form.has_key("searchPattern") and Form.has_key("search"):
+    Searching = 1
+    expression = Form['searchPattern'].value % Form['search'].value
+    flags = re.M
+    # TODO: Decide about case-insensitive searching.
+    #       It could be done by default or an HTML for checkbox.
+    # To implement case-insensitive searching:
+    # flags = flags | re.I
+
+    # TODO: Improve this efficiency, if possible.
+    #       It can be horribly slow if there are many pending messages.
+    #
+    # Current search algorithm:
+    # - For each message in the pending queue:
+    #   - Do a Python RE match for the expression
+    #   - If it matches, add it to the list.
+    exp = re.compile(expression, flags)
+    matchingMsgs = []
+    for Msg in Msgs:
+      try:
+        MsgObj = Pending.Message(Msg)
+      except (IOError, Errors.MessageError), ErrStr:
+        continue
+      if exp.search( MsgObj.show() ) != None:
+        matchingMsgs = matchingMsgs + [ Msg ]
+    Msgs = matchingMsgs
+    # TODO: Catch the error which results if no matches are found.
+
   # Mark messages as read if necessary
   for MsgObj in ReadList:
     # Mark as Read
@@ -189,6 +230,15 @@
   T = Template.Template("pending.html")
   T["CharSet"] = "utf-8"
   T["MsgID"]   = ""
+
+  if Searching:
+    # TODO: If searching, we must either:
+    #       - Save the search results from page to page
+    #       - Show all the search results in the one page, disregarding 
+    #         pager settings
+    T['searchForm']
+  else:
+    T['clearSearch']
 
   # Find the message numbers we'll display
   FirstMsg = PVars["Pager"]

Index: TODO
===================================================================
RCS file: /cvsroot/tmda/tmda-cgi/TODO,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- TODO	13 Jul 2003 18:43:34 -0000	1.23
+++ TODO	4 Dec 2003 17:30:47 -0000	1.24
@@ -15,4 +15,5 @@
 
     * Remember Me -- set a cookie to skip login
 
-    * Search -- for pending list and/or lists and filters
+    * Search -- Improve pending list search and implement for lists and/or
+                filters

Index: ChangeLog
===================================================================
RCS file: /cvsroot/tmda/tmda-cgi/ChangeLog,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -r1.71 -r1.72
--- ChangeLog	24 Nov 2003 18:21:32 -0000	1.71
+++ ChangeLog	4 Dec 2003 17:30:47 -0000	1.72
@@ -1,3 +1,8 @@
+2003-12-04  Jim Ramsay      <[email protected]>
+
+	* Added preliminary searching in the Pending List and the Blue theme.
+	  This should be refined / bugtested.
+
 2003-11-24  Gre7g Luterman  <[email protected]>
 
 	* Changed configure to strip slashes from DispDir to keep Netscape
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.