Skip to content

Commit bbefb80

Browse files
author
Richard Jones
committed
roundup-admin reindex command may now work on single items or classes
1 parent 9253a10 commit bbefb80

File tree

6 files changed

+45
-16
lines changed

6 files changed

+45
-16
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Feature:
2424
Permissions.
2525
- added option to turn off registration confirmation via email
2626
("instant_registration" in config) (sf rfe 922209)
27+
- roundup-admin reindex command may now work on single items or classes
2728

2829

2930
2004-??-?? 0.7.7
@@ -33,6 +34,7 @@ Fixed:
3334
- removed references to py2.3+ boolean values (sf bug 995682)
3435

3536

37+
3638
2004-07-21 0.7.6
3739
Fixed:
3840
- rdbms backend full text search failure after import (sf bug 980314)

TODO.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Required:
1010
- fix documentation referring to customisation using interfaces.py
1111
- fix admin_guide referring to structure of trackers
1212
- add config.ini section descriptions
13+
- review use of hasPermission etc. in classic template
1314

1415

1516
Optionally:

roundup/admin.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1717
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1818
#
19-
# $Id: admin.py,v 1.77 2004-07-27 00:57:17 richard Exp $
19+
# $Id: admin.py,v 1.78 2004-07-28 05:00:30 richard Exp $
2020

2121
'''Administration commands for maintaining Roundup trackers.
2222
'''
@@ -1154,15 +1154,28 @@ def do_pack(self, args):
11541154
self.db.pack(pack_before)
11551155
return 0
11561156

1157-
def do_reindex(self, args):
1158-
""'''Usage: reindex
1157+
def do_reindex(self, args, desre=re.compile('([A-Za-z]+)([0-9]+)')):
1158+
'''Usage: reindex [classname|designator]*
11591159
Re-generate a tracker's search indexes.
11601160
1161-
This will re-generate the search indexes for a tracker.
1162-
This will typically happen automatically.
1161+
This will re-generate the search indexes for a tracker. This will
1162+
typically happen automatically.
11631163
'''
1164-
self.db.indexer.force_reindex()
1165-
self.db.reindex()
1164+
if args:
1165+
for arg in args:
1166+
m = desre.match(arg)
1167+
if m:
1168+
cl = self.get_class(m.group(1))
1169+
try:
1170+
cl.index(m.group(2))
1171+
except IndexError:
1172+
raise UsageError, _('no such item "%(designator)s"')%{
1173+
'designator': arg}
1174+
else:
1175+
cl = self.get_class(arg)
1176+
self.db.reindex(arg)
1177+
else:
1178+
self.db.reindex()
11661179
return 0
11671180

11681181
def do_security(self, args):

roundup/backends/back_anydbm.py

Lines changed: 7 additions & 3 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: back_anydbm.py,v 1.170 2004-07-28 02:29:45 richard Exp $
18+
#$Id: back_anydbm.py,v 1.171 2004-07-28 05:00:31 richard Exp $
1919
'''This module defines a backend that saves the hyperdatabase in a
2020
database chosen by anydbm. It is guaranteed to always be available in python
2121
versions >2.1.1 (the dumbdbm fallback in 2.1.1 and earlier has several
@@ -119,8 +119,12 @@ def getSessionManager(self):
119119
def getOTKManager(self):
120120
return OneTimeKeys(self)
121121

122-
def reindex(self):
123-
for klass in self.classes.values():
122+
def reindex(self, classname=None):
123+
if classname:
124+
classes = [self.getclass(classname)]
125+
else:
126+
classes = self.classes.values()
127+
for klass in classes:
124128
for nodeid in klass.list():
125129
klass.index(nodeid)
126130
self.indexer.save_index()

roundup/backends/back_metakit.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: back_metakit.py,v 1.83 2004-07-28 02:29:45 richard Exp $
1+
# $Id: back_metakit.py,v 1.84 2004-07-28 05:00:31 richard Exp $
22
'''Metakit backend for Roundup, originally by Gordon McMillan.
33
44
Known Current Bugs:
@@ -104,8 +104,12 @@ def refresh_database(self):
104104
# XXX handle refresh
105105
self.reindex()
106106

107-
def reindex(self):
108-
for klass in self.classes.values():
107+
def reindex(self, classname=None):
108+
if classname:
109+
classes = [self.getclass(classname)]
110+
else:
111+
classes = self.classes.values()
112+
for klass in classes:
109113
for nodeid in klass.list():
110114
klass.index(nodeid)
111115
self.indexer.save_index()

roundup/backends/rdbms_common.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: rdbms_common.py,v 1.127 2004-07-28 02:29:45 richard Exp $
1+
# $Id: rdbms_common.py,v 1.128 2004-07-28 05:00:32 richard Exp $
22
''' Relational database (SQL) backend common code.
33
44
Basics:
@@ -298,8 +298,13 @@ def _convert_string_properties(self):
298298
def refresh_database(self):
299299
self.post_init()
300300

301-
def reindex(self):
302-
for klass in self.classes.values():
301+
302+
def reindex(self, classname=None):
303+
if classname:
304+
classes = [self.getclass(classname)]
305+
else:
306+
classes = self.classes.values()
307+
for klass in classes:
303308
for nodeid in klass.list():
304309
klass.index(nodeid)
305310
self.indexer.save_index()

0 commit comments

Comments
 (0)