Skip to content

Commit f58c785

Browse files
author
Richard Jones
committed
Class.find() may now find unset Links [SF#700620]
1 parent 438a703 commit f58c785

File tree

6 files changed

+80
-66
lines changed

6 files changed

+80
-66
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Feature:
5353
- more lenient date input and addition Interval input support (sf bug 677764)
5454
- roundup mailgw now handles apop
5555
- implemented ability to search for multilink properties with no value
56+
- Class.find() may now find unset Links (sf bug 700620)
5657

5758

5859
Fixed:

roundup/admin.py

Lines changed: 4 additions & 2 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.47 2003-03-23 09:37:20 richard Exp $
19+
# $Id: admin.py,v 1.48 2003-03-26 10:43:58 richard Exp $
2020

2121
'''Administration commands for maintaining Roundup trackers.
2222
'''
@@ -541,7 +541,9 @@ def do_find(self, args):
541541
# number
542542
for propname, value in props.items():
543543
num_re = re.compile('^\d+$')
544-
if not num_re.match(value):
544+
if value == '-1':
545+
props[propname] = None
546+
elif not num_re.match(value):
545547
# get the property
546548
try:
547549
property = cl.properties[propname]

roundup/backends/back_anydbm.py

Lines changed: 19 additions & 17 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.116 2003-03-26 05:30:23 richard Exp $
18+
#$Id: back_anydbm.py,v 1.117 2003-03-26 10:43:59 richard 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
@@ -1462,23 +1462,23 @@ def lookup(self, keyvalue):
14621462

14631463
# change from spec - allows multiple props to match
14641464
def find(self, **propspec):
1465-
'''Get the ids of nodes in this class which link to the given nodes.
1465+
'''Get the ids of items in this class which link to the given items.
14661466
1467-
'propspec' consists of keyword args propname=nodeid or
1468-
propname={nodeid:1, }
1467+
'propspec' consists of keyword args propname=itemid or
1468+
propname={itemid:1, }
14691469
'propname' must be the name of a property in this class, or a
14701470
KeyError is raised. That property must be a Link or
14711471
Multilink property, or a TypeError is raised.
14721472
1473-
Any node in this class whose 'propname' property links to any of the
1474-
nodeids will be returned. Used by the full text indexing, which knows
1473+
Any item in this class whose 'propname' property links to any of the
1474+
itemids will be returned. Used by the full text indexing, which knows
14751475
that "foo" occurs in msg1, msg3 and file7, so we have hits on these
14761476
issues:
14771477
14781478
db.issue.find(messages={'1':1,'3':1}, files={'7':1})
14791479
'''
14801480
propspec = propspec.items()
1481-
for propname, nodeids in propspec:
1481+
for propname, itemids in propspec:
14821482
# check the prop is OK
14831483
prop = self.properties[propname]
14841484
if not isinstance(prop, Link) and not isinstance(prop, Multilink):
@@ -1489,24 +1489,26 @@ def find(self, **propspec):
14891489
l = []
14901490
try:
14911491
for id in self.getnodeids(db=cldb):
1492-
node = self.db.getnode(self.classname, id, db=cldb)
1493-
if node.has_key(self.db.RETIRED_FLAG):
1492+
item = self.db.getnode(self.classname, id, db=cldb)
1493+
if item.has_key(self.db.RETIRED_FLAG):
14941494
continue
1495-
for propname, nodeids in propspec:
1496-
# can't test if the node doesn't have this property
1497-
if not node.has_key(propname):
1495+
for propname, itemids in propspec:
1496+
# can't test if the item doesn't have this property
1497+
if not item.has_key(propname):
14981498
continue
1499-
if type(nodeids) is type(''):
1500-
nodeids = {nodeids:1}
1499+
if type(itemids) is not type({}):
1500+
itemids = {itemids:1}
1501+
1502+
# grab the property definition and its value on this item
15011503
prop = self.properties[propname]
1502-
value = node[propname]
1503-
if isinstance(prop, Link) and nodeids.has_key(value):
1504+
value = item[propname]
1505+
if isinstance(prop, Link) and itemids.has_key(value):
15041506
l.append(id)
15051507
break
15061508
elif isinstance(prop, Multilink):
15071509
hit = 0
15081510
for v in value:
1509-
if nodeids.has_key(v):
1511+
if itemids.has_key(v):
15101512
l.append(id)
15111513
hit = 1
15121514
break

roundup/backends/back_metakit.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: back_metakit.py,v 1.44 2003-03-26 06:36:11 richard Exp $
1+
# $Id: back_metakit.py,v 1.45 2003-03-26 10:44:00 richard Exp $
22
'''
33
Metakit backend for Roundup, originally by Gordon McMillan.
44
@@ -17,7 +17,7 @@
1717
Interval '' convert to None
1818
Number 0 ambiguious :( - do nothing
1919
Boolean 0 ambiguious :( - do nothing
20-
Link '' convert to None
20+
Link 0 convert to None
2121
Multilink [] actually, mk can handle this one ;)
2222
Passowrd '' convert to None
2323
========= ===== ====================================================
@@ -821,6 +821,8 @@ def find(self, **propspec):
821821
for propname, ids in propspec:
822822
if type(ids) is _STRINGTYPE:
823823
ids = {int(ids):1}
824+
elif ids is None:
825+
ids = {0:1}
824826
else:
825827
d = {}
826828
for id in ids.keys():

roundup/backends/rdbms_common.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: rdbms_common.py,v 1.51 2003-03-26 05:29:06 richard Exp $
1+
# $Id: rdbms_common.py,v 1.52 2003-03-26 10:44:03 richard Exp $
22
''' Relational database (SQL) backend common code.
33
44
Basics:
@@ -1673,6 +1673,8 @@ def find(self, **propspec):
16731673
if type(values) is type(''):
16741674
allvalues += (values,)
16751675
where.append('_%s = %s'%(prop, a))
1676+
elif values is None:
1677+
where.append('_%s is NULL'%prop)
16761678
else:
16771679
allvalues += tuple(values.keys())
16781680
where.append('_%s in (%s)'%(prop, ','.join([a]*len(values))))

0 commit comments

Comments
 (0)