Skip to content

Commit 0eb89fe

Browse files
author
Gordon B. McMillan
committed
Use same regex to split search terms as used to index text.
Fix to back_metakit for not changing journaltag on reopen. Fix htmltemplate's do_link so [No <whatever>] strings are href'd. Fix bogus "nosy edited ok" msg - the **d syntax does NOT share d between caller and callee.
1 parent d8ebc80 commit 0eb89fe

File tree

4 files changed

+49
-12
lines changed

4 files changed

+49
-12
lines changed

roundup/backends/back_anydbm.py

Lines changed: 8 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.57 2002-07-31 23:57:36 richard Exp $
18+
#$Id: back_anydbm.py,v 1.58 2002-08-01 15:06:24 gmcm 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
@@ -944,7 +944,7 @@ class or a KeyError is raised.
944944
to modify the "creation" or "activity" properties cause a KeyError.
945945
"""
946946
if not propvalues:
947-
return
947+
return propvalues
948948

949949
if propvalues.has_key('creation') or propvalues.has_key('activity'):
950950
raise KeyError, '"creation" and "activity" are reserved'
@@ -1124,7 +1124,7 @@ class or a KeyError is raised.
11241124

11251125
# nothing to do?
11261126
if not propvalues:
1127-
return
1127+
return propvalues
11281128

11291129
# do the set, and journal it
11301130
self.db.setnode(self.classname, nodeid, node)
@@ -1135,6 +1135,8 @@ class or a KeyError is raised.
11351135

11361136
self.fireReactors('set', nodeid, oldvalues)
11371137

1138+
return propvalues
1139+
11381140
def retire(self, nodeid):
11391141
"""Retire a node.
11401142
@@ -1793,6 +1795,9 @@ def __init__(self, db, classname, **properties):
17931795

17941796
#
17951797
#$Log: not supported by cvs2svn $
1798+
#Revision 1.57 2002/07/31 23:57:36 richard
1799+
# . web forms may now unset Link values (like assignedto)
1800+
#
17961801
#Revision 1.56 2002/07/31 22:04:33 richard
17971802
#cleanup
17981803
#

roundup/backends/back_metakit.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ def Database(config, journaltag=None):
1212
if db is None or db._db is None:
1313
db = _Database(config, journaltag)
1414
_dbs[config.DATABASE] = db
15+
else:
16+
db.journaltag = journaltag
17+
try:
18+
delattr(db, 'curuserid')
19+
except AttributeError:
20+
pass
1521
return db
1622

1723
class _Database(hyperdb.Database):
@@ -273,7 +279,7 @@ def set(self, nodeid, **propvalues):
273279
if not isnew:
274280
self.fireAuditors('set', nodeid, propvalues)
275281
if not propvalues:
276-
return
282+
return propvalues
277283
if propvalues.has_key('id'):
278284
raise KeyError, '"id" is reserved'
279285
if self.db.journaltag is None:
@@ -328,6 +334,9 @@ def set(self, nodeid, **propvalues):
328334
if value is not None and not isinstance(value, type('')):
329335
raise ValueError, 'property "%s" link value be a string'%(
330336
propname)
337+
# Roundup sets to "unselected" by passing None
338+
if value is None:
339+
value = 0
331340
# if it isn't a number, it's a key
332341
try:
333342
int(value)
@@ -408,6 +417,8 @@ def set(self, nodeid, **propvalues):
408417
for id in adds:
409418
sv.append(fid=int(id))
410419
changes[key] = oldvalue
420+
if not rmvd and not adds:
421+
del propvalues[key]
411422

412423

413424
elif isinstance(prop, hyperdb.String):
@@ -456,7 +467,7 @@ def set(self, nodeid, **propvalues):
456467

457468
# nothing to do?
458469
if not propvalues:
459-
return
470+
return propvalues
460471
if not propvalues.has_key('activity'):
461472
row.activity = int(time.time())
462473
if isnew:
@@ -474,6 +485,8 @@ def set(self, nodeid, **propvalues):
474485
self.db.addjournal(self.classname, nodeid, _SET, changes)
475486
self.fireReactors('set', nodeid, oldnode)
476487

488+
return propvalues
489+
477490
def retire(self, nodeid):
478491
self.fireAuditors('retire', nodeid, None)
479492
view = self.getview(1)

roundup/cgi_client.py

Lines changed: 9 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: cgi_client.py,v 1.155 2002-08-01 00:56:22 richard Exp $
18+
# $Id: cgi_client.py,v 1.156 2002-08-01 15:06:06 gmcm Exp $
1919

2020
__doc__ = """
2121
WWW request handler (also used in the stand-alone server).
@@ -717,7 +717,7 @@ def shownode(self, message=None, num_re=re.compile('^\d+$')):
717717
else:
718718
props = parsePropsFromForm(self.db, cl, self.form, self.nodeid)
719719
# make changes to the node
720-
self._changenode(props)
720+
props = self._changenode(props)
721721
# handle linked nodes
722722
self._post_editnode(self.nodeid)
723723
# and some nice feedback for the user
@@ -814,7 +814,7 @@ def _changenode(self, props):
814814
props['files'] = cl.get(self.nodeid, 'files') + files
815815

816816
# make the changes
817-
cl.set(self.nodeid, **props)
817+
return cl.set(self.nodeid, **props)
818818

819819
def _createnode(self):
820820
''' create a node based on the contents of the form
@@ -1703,6 +1703,12 @@ def parsePropsFromForm(db, cl, form, nodeid=0, num_re=re.compile('^\d+$')):
17031703

17041704
#
17051705
# $Log: not supported by cvs2svn $
1706+
# Revision 1.155 2002/08/01 00:56:22 richard
1707+
# Added the web access and email access permissions, so people can restrict
1708+
# access to users who register through the email interface (for example).
1709+
# Also added "security" command to the roundup-admin interface to display the
1710+
# Role/Permission config for an instance.
1711+
#
17061712
# Revision 1.154 2002/07/31 23:57:36 richard
17071713
# . web forms may now unset Link values (like assignedto)
17081714
#

roundup/htmltemplate.py

Lines changed: 17 additions & 4 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: htmltemplate.py,v 1.108 2002-07-31 22:40:50 gmcm Exp $
18+
# $Id: htmltemplate.py,v 1.109 2002-08-01 15:06:08 gmcm Exp $
1919

2020
__doc__ = """
2121
Template engine.
@@ -403,13 +403,13 @@ def do_link(self, property=None, is_download=0, showid=0):
403403

404404
# get the value
405405
value = self.determine_value(property)
406-
if value in ('', None, []):
407-
return _('[no %(propname)s]')%{'propname':property.capitalize()}
408406

409407
propclass = self.properties[property]
410408
if isinstance(propclass, hyperdb.Boolean):
411409
value = value and "Yes" or "No"
412410
elif isinstance(propclass, hyperdb.Link):
411+
if value in ('', None, []):
412+
return _('[no %(propname)s]')%{'propname':property.capitalize()}
413413
linkname = propclass.classname
414414
linkcl = self.db.classes[linkname]
415415
k = linkcl.labelprop(1)
@@ -427,6 +427,8 @@ def do_link(self, property=None, is_download=0, showid=0):
427427
else:
428428
return '<a href="%s%s"%s>%s</a>'%(linkname, value, title, label)
429429
elif isinstance(propclass, hyperdb.Multilink):
430+
if value in ('', None, []):
431+
return _('[no %(propname)s]')%{'propname':property.capitalize()}
430432
linkname = propclass.classname
431433
linkcl = self.db.classes[linkname]
432434
k = linkcl.labelprop(1)
@@ -448,9 +450,13 @@ def do_link(self, property=None, is_download=0, showid=0):
448450
title, label))
449451
return ', '.join(l)
450452
if is_download:
453+
if value in ('', None, []):
454+
return _('[no %(propname)s]')%{'propname':property.capitalize()}
451455
return '<a href="%s%s/%s">%s</a>'%(self.classname, self.nodeid,
452456
value, value)
453457
else:
458+
if value in ('', None, []):
459+
value = _('[no %(propname)s]')%{'propname':property.capitalize()}
454460
return '<a href="%s%s">%s</a>'%(self.classname, self.nodeid, value)
455461

456462
def do_count(self, property, **args):
@@ -929,6 +935,7 @@ def __init__(self, client, templates, classname):
929935

930936
def clear(self):
931937
self.db = self.cl = self.properties = None
938+
del self.globals['handle_require']
932939
TemplateFunctions.clear(self)
933940

934941
def buildurl(self, filterspec, search_text, filter, columns, sort, group, pagesize):
@@ -1019,7 +1026,8 @@ def render(self, filterspec={}, search_text='', filter=[], columns=[],
10191026
if nodeids is None:
10201027
if search_text != '':
10211028
matches = self.db.indexer.search(
1022-
search_text.split(' '), self.cl)
1029+
re.findall(r'\b\w{2,25}\b', search_text), self.cl)
1030+
#search_text.split(' '), self.cl)
10231031
nodeids = self.cl.filter(matches, filterspec, sort, group)
10241032
for nodeid in nodeids[startwith:startwith+pagesize]:
10251033
# check for a group heading
@@ -1351,6 +1359,7 @@ def __init__(self, client, templates, classname):
13511359

13521360
def clear(self):
13531361
self.db = self.cl = self.properties = None
1362+
del self.globals['handle_require']
13541363
TemplateFunctions.clear(self)
13551364

13561365
def render(self, nodeid):
@@ -1441,6 +1450,10 @@ def render(self, form):
14411450

14421451
#
14431452
# $Log: not supported by cvs2svn $
1453+
# Revision 1.108 2002/07/31 22:40:50 gmcm
1454+
# Fixes to the search form and saving queries.
1455+
# Fixes to sorting in back_metakit.py.
1456+
#
14441457
# Revision 1.107 2002/07/30 05:27:30 richard
14451458
# nicer error messages, and a bugfix
14461459
#

0 commit comments

Comments
 (0)