CVS: tmda-cgi ChangeLog,1.72,1.73 PendList.py,1.28,1.29
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-serv22787 Modified Files: ChangeLog PendList.py Log Message: Increase search efficiency for header searches (now uses Pending.Message.msgobj[header]) Index: ChangeLog =================================================================== RCS file: /cvsroot/tmda/tmda-cgi/ChangeLog,v retrieving revision 1.72 retrieving revision 1.73 diff -u -r1.72 -r1.73 --- ChangeLog 4 Dec 2003 17:30:47 -0000 1.72 +++ ChangeLog 6 Dec 2003 22:26:39 -0000 1.73 @@ -1,7 +1,15 @@ +2003-12-06 Jim Ramsay <[email protected]> + + * Improved efficiency for header searching. + 2003-12-04 Jim Ramsay <[email protected]> * Added preliminary searching in the Pending List and the Blue theme. This should be refined / bugtested. + + * Moved some theme specific data (graphic filenames for inactive + first/prev/next/last buttons) from PendList.py and View.py into pending.ht + and view.ht instead. 2003-11-24 Gre7g Luterman <[email protected]> Index: PendList.py =================================================================== RCS file: /cvsroot/tmda/tmda-cgi/PendList.py,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- PendList.py 4 Dec 2003 22:40:56 -0000 1.28 +++ PendList.py 6 Dec 2003 22:26:39 -0000 1.29 @@ -187,20 +187,30 @@ 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 + # By default, set no flags. + flags = 0 + + # Check what sort of search - a full body search or just a header search + if( re.search( '%s', Form['searchPattern'].value ) ): + searchScope = 'fullMessage' + expression = Form['searchPattern'].value % Form['search'].value + # Do a multiline search through the entire message, matching a newline + # with '.' + flags = re.MULTILINE | re.DOTALL + elif( re.match( '^_header:', Form['searchPattern'].value ) ): + ( searchScope, headerList ) = Form['searchPattern'].value.split(':') + headerList = headerList.split(',') + expression = Form['search'].value + elif( Form['searchPattern'].value == "_header" and \ + Form.has_key("searchHeaderList" ) ): + searchScope = Form['searchPattern'].value + headerList = Form['searchHeaderList'].value.split(',') + expression = Form['search'].value + + # Assume case-insensitive unless the form has 'searchCaseSensitive' + if not Form.has_key("searchCaseSensitive"): + 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: @@ -208,8 +218,17 @@ MsgObj = Pending.Message(Msg) except (IOError, Errors.MessageError), ErrStr: continue - if exp.search( MsgObj.show() ) != None: + # Slow search - Search the fulltext of the message + if searchScope == 'fullMessage' and \ + exp.search( MsgObj.show() ) != None: matchingMsgs = matchingMsgs + [ Msg ] + # Faster search - just matches a header + elif searchScope == '_header': + for header in headerList: + if MsgObj.msgobj.has_key( header ) and \ + exp.search( MsgObj.msgobj[ header ] ): + matchingMsgs = matchingMsgs + [ Msg ] + break Msgs = matchingMsgs # TODO: Catch the error which results if no matches are found.