1515# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717#
18- # $Id: cgi_client.py,v 1.124 2002-05-24 02:09 :24 richard Exp $
18+ # $Id: cgi_client.py,v 1.125 2002-05-25 07:16 :24 rochecompaan Exp $
1919
2020__doc__ = """
2121WWW request handler (also used in the stand-alone server).
2626
2727import roundupdb , htmltemplate , date , hyperdb , password
2828from roundup .i18n import _
29+ from roundup_indexer import RoundupIndexer
2930
3031class Unauthorised (ValueError ):
3132 pass
@@ -71,6 +72,7 @@ def __init__(self, instance, request, env, form=None):
7172 except ValueError :
7273 # someone gave us a non-int debug level, turn it off
7374 self .debug = 0
75+ self .indexer = RoundupIndexer ('%s/db' % instance .INSTANCE_HOME )
7476
7577 def getuid (self ):
7678 return self .db .user .lookup (self .user )
@@ -212,6 +214,17 @@ def pagehead(self, title, message=None):
212214 links .append (_ ('<a href="user">User List</a>' ))
213215 links .append (_ ('<a href="newuser">Add User</a>' ))
214216
217+ # add the search links
218+ if hasattr (self .instance , 'HEADER_SEARCH_LINKS' ):
219+ classes = self .instance .HEADER_SEARCH_LINKS
220+ else :
221+ classes = ['issue' ]
222+ l = []
223+ for class_name in classes :
224+ cap_class = class_name .capitalize ()
225+ links .append (_ ('Search <a href="search%(class_name)s">'
226+ '%(cap_class)s</a>' )% locals ())
227+
215228 # now we have all the links, join 'em
216229 links = '\n | ' .join (links )
217230
@@ -331,9 +344,7 @@ def customization_widget(self):
331344 default_index_columns = ['id' ,'activity' ,'title' ,'status' ,'assignedto' ]
332345 default_index_filterspec = {'status' : ['1' , '2' , '3' , '4' , '5' , '6' , '7' ]}
333346
334- def index (self ):
335- ''' put up an index - no class specified
336- '''
347+ def _get_customisation_info (self ):
337348 # see if the web has supplied us with any customisation info
338349 defaults = 1
339350 for key in ':sort' , ':group' , ':filter' , ':columns' :
@@ -363,13 +374,39 @@ def index(self):
363374 # make list() extract the info from the CGI environ
364375 self .classname = 'issue'
365376 sort = group = filter = columns = filterspec = None
377+ return columns , filter , group , sort , filterspec
378+
379+ def index (self ):
380+ ''' put up an index - no class specified
381+ '''
382+ columns , filter , group , sort , filterspec = \
383+ self ._get_customisation_info ()
366384 return self .list (columns = columns , filter = filter , group = group ,
367385 sort = sort , filterspec = filterspec )
368386
387+ def searchnode (self ):
388+ columns , filter , group , sort , filterspec = \
389+ self ._get_customisation_info ()
390+ show_nodes = 1
391+ if len (self .form .keys ()) == 0 :
392+ # get the default search filters from instance_config
393+ if hasattr (self .instance , 'SEARCH_FILTERS' ):
394+ for f in self .instance .SEARCH_FILTERS :
395+ spec = getattr (self .instance , f )
396+ if spec ['CLASS' ] == self .classname :
397+ filter = spec ['FILTER' ]
398+
399+ show_nodes = 0
400+ show_customization = 1
401+ return self .list (columns = columns , filter = filter , group = group ,
402+ sort = sort , filterspec = filterspec ,
403+ show_customization = show_customization , show_nodes = show_nodes )
404+
405+
369406 # XXX deviates from spec - loses the '+' (that's a reserved character
370407 # in URLS
371408 def list (self , sort = None , group = None , filter = None , columns = None ,
372- filterspec = None , show_customization = None ):
409+ filterspec = None , show_customization = None , show_nodes = 1 ):
373410 ''' call the template index with the args
374411
375412 :sort - sort by prop name, optionally preceeded with '-'
@@ -393,11 +430,16 @@ def list(self, sort=None, group=None, filter=None, columns=None,
393430 if filterspec is None : filterspec = self .index_filterspec (filter )
394431 if show_customization is None :
395432 show_customization = self .customization_widget ()
433+ if self .form .has_key ('search_text' ):
434+ search_text = self .form ['search_text' ].value
435+ else :
436+ search_text = ''
396437
397438 index = htmltemplate .IndexTemplate (self , self .instance .TEMPLATES , cn )
398439 try :
399- index .render (filterspec , filter , columns , sort , group ,
400- show_customization = show_customization )
440+ index .render (filterspec , search_text , filter , columns , sort ,
441+ group , show_customization = show_customization ,
442+ show_nodes = show_nodes )
401443 except htmltemplate .MissingTemplateError :
402444 self .basicClassEditPage ()
403445 self .pagefoot ()
@@ -560,6 +602,7 @@ def shownode(self, message=None):
560602 self .pagefoot ()
561603 showissue = shownode
562604 showmsg = shownode
605+ searchissue = searchnode
563606
564607 def _add_author_to_nosy (self , props ):
565608 ''' add the author value from the props to the nosy list
@@ -1243,7 +1286,7 @@ def main(self):
12431286 self .db .commit ()
12441287
12451288 def do_action (self , action , dre = re .compile (r'([^\d]+)(\d+)' ),
1246- nre = re .compile (r'new(\w+)' )):
1289+ nre = re .compile (r'new(\w+)' ), sre = re . compile ( r'search(\w+)' ) ):
12471290 '''Figure the user's action and do it.
12481291 '''
12491292 # here be the "normal" functionality
@@ -1294,6 +1337,17 @@ def do_action(self, action, dre=re.compile(r'([^\d]+)(\d+)'),
12941337 func ()
12951338 return
12961339
1340+ # see if we're to put up the new node page
1341+ m = sre .match (action )
1342+ if m :
1343+ self .classname = m .group (1 )
1344+ try :
1345+ func = getattr (self , 'search%s' % self .classname )
1346+ except AttributeError :
1347+ raise NotFound
1348+ func ()
1349+ return
1350+
12971351 # otherwise, display the named class
12981352 self .classname = action
12991353 try :
@@ -1311,6 +1365,7 @@ class ExtendedClient(Client):
13111365 showtimelog = Client .shownode
13121366 newsupport = Client .newnode
13131367 newtimelog = Client .newnode
1368+ searchsupport = Client .searchnode
13141369
13151370 default_index_sort = ['-activity' ]
13161371 default_index_group = ['priority' ]
@@ -1399,6 +1454,9 @@ def parsePropsFromForm(db, cl, form, nodeid=0):
13991454
14001455#
14011456# $Log: not supported by cvs2svn $
1457+ # Revision 1.124 2002/05/24 02:09:24 richard
1458+ # Nothing like a live demo to show up the bugs ;)
1459+ #
14021460# Revision 1.123 2002/05/22 05:04:13 richard
14031461# Oops
14041462#
@@ -1434,6 +1492,29 @@ def parsePropsFromForm(db, cl, form, nodeid=0):
14341492# Revision 1.115 2002/04/02 01:56:10 richard
14351493# . stop sending blank (whitespace-only) notes
14361494#
1495+ # Revision 1.114.2.4 2002/05/02 11:49:18 rochecompaan
1496+ # Allow customization of the search filters that should be displayed
1497+ # on the search page.
1498+ #
1499+ # Revision 1.114.2.3 2002/04/20 13:23:31 rochecompaan
1500+ # We now have a separate search page for nodes. Search links for
1501+ # different classes can be customized in instance_config similar to
1502+ # index links.
1503+ #
1504+ # Revision 1.114.2.2 2002/04/19 19:54:42 rochecompaan
1505+ # cgi_client.py
1506+ # removed search link for the time being
1507+ # moved rendering of matches to htmltemplate
1508+ # hyperdb.py
1509+ # filtering of nodes on full text search incorporated in filter method
1510+ # roundupdb.py
1511+ # added paramater to call of filter method
1512+ # roundup_indexer.py
1513+ # added search method to RoundupIndexer class
1514+ #
1515+ # Revision 1.114.2.1 2002/04/03 11:55:57 rochecompaan
1516+ # . Added feature #526730 - search for messages capability
1517+ #
14371518# Revision 1.114 2002/03/17 23:06:05 richard
14381519# oops
14391520#
0 commit comments