Skip to content

Commit bdb9d08

Browse files
author
Roche Compaan
committed
Merged search_indexing-branch with HEAD
1 parent 7d069de commit bdb9d08

File tree

11 files changed

+1247
-69
lines changed

11 files changed

+1247
-69
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Feature:
3232
. applied patch #558876 ] cgi client customization
3333
. split instance initialisation into two steps, allowing config changes
3434
before the database is initialised.
35+
. #526730 ] search for messages capability
3536

3637
Fixed:
3738
. stop sending blank (whitespace-only) notes

roundup/backends/back_anydbm.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
#$Id: back_anydbm.py,v 1.34 2002-05-15 06:21:21 richard Exp $
18+
#$Id: back_anydbm.py,v 1.35 2002-05-25 07:16:24 rochecompaan Exp $
1919
'''
2020
This module defines a backend that saves the hyperdatabase in a database
2121
chosen by anydbm. It is guaranteed to always be available in python
@@ -26,6 +26,7 @@
2626
import whichdb, anydbm, os, marshal
2727
from roundup import hyperdb, date
2828
from blobfiles import FileStorage
29+
from roundup.roundup_indexer import RoundupIndexer
2930
from locking import acquire_lock, release_lock
3031

3132
#
@@ -61,6 +62,7 @@ def __init__(self, config, journaltag=None):
6162
self.dirtynodes = {} # keep track of the dirty nodes by class
6263
self.newnodes = {} # keep track of the new nodes by class
6364
self.transactions = []
65+
self.indexer = RoundupIndexer(self.dir)
6466
# ensure files are group readable and writable
6567
os.umask(0002)
6668

@@ -467,6 +469,9 @@ def _doSaveJournal(self, classname, nodeid, action, params):
467469
def _doStoreFile(self, name, **databases):
468470
# the file is currently ".tmp" - move it to its real name to commit
469471
os.rename(name+".tmp", name)
472+
pattern = name.split('/')[-1]
473+
self.indexer.add_files(dir=os.path.dirname(name), pattern=pattern)
474+
self.indexer.save_index()
470475

471476
def rollback(self):
472477
''' Reverse all actions from the current transaction.
@@ -485,6 +490,14 @@ def rollback(self):
485490

486491
#
487492
#$Log: not supported by cvs2svn $
493+
#Revision 1.34 2002/05/15 06:21:21 richard
494+
# . node caching now works, and gives a small boost in performance
495+
#
496+
#As a part of this, I cleaned up the DEBUG output and implemented TRACE
497+
#output (HYPERDBTRACE='file to trace to') with checkpoints at the start of
498+
#CGI requests. Run roundup with python -O to skip all the DEBUG/TRACE stuff
499+
#(using if __debug__ which is compiled out with -O)
500+
#
488501
#Revision 1.33 2002/04/24 10:38:26 rochecompaan
489502
#All database files are now created group readable and writable.
490503
#
@@ -502,6 +515,9 @@ def rollback(self):
502515
#
503516
#Unit tests for all of the above written.
504517
#
518+
#Revision 1.30.2.1 2002/04/03 11:55:57 rochecompaan
519+
# . Added feature #526730 - search for messages capability
520+
#
505521
#Revision 1.30 2002/02/27 03:40:59 richard
506522
#Ran it through pychecker, made fixes
507523
#

roundup/cgi_client.py

Lines changed: 89 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
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__ = """
2121
WWW request handler (also used in the stand-alone server).
@@ -26,6 +26,7 @@
2626

2727
import roundupdb, htmltemplate, date, hyperdb, password
2828
from roundup.i18n import _
29+
from roundup_indexer import RoundupIndexer
2930

3031
class 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

Comments
 (0)