Skip to content

Commit 7421d07

Browse files
author
Richard Jones
committed
fix anydbm so search for None Link value works...
...also tweak query edit so its a little more useful
1 parent ed7ae90 commit 7421d07

File tree

2 files changed

+42
-40
lines changed

2 files changed

+42
-40
lines changed

roundup/backends/back_anydbm.py

Lines changed: 40 additions & 38 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.146.2.9 2004-06-13 01:11:23 richard Exp $
18+
#$Id: back_anydbm.py,v 1.146.2.10 2004-06-21 05:42:45 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
@@ -1599,12 +1599,12 @@ def filter(self, search_matches, filterspec, sort=(None,None),
15991599
# optimise filterspec
16001600
l = []
16011601
props = self.getprops()
1602-
LINK = 0
1603-
MULTILINK = 1
1604-
STRING = 2
1605-
DATE = 3
1606-
INTERVAL = 4
1607-
OTHER = 6
1602+
LINK = 'spec:link'
1603+
MULTILINK = 'spec:multilink'
1604+
STRING = 'spec:string'
1605+
DATE = 'spec:date'
1606+
INTERVAL = 'spec:interval'
1607+
OTHER = 'spec:other'
16081608

16091609
timezone = self.db.getUserTimezone()
16101610
for k, v in filterspec.items():
@@ -1689,56 +1689,58 @@ def filter(self, search_matches, filterspec, sort=(None,None),
16891689
# apply filter
16901690
for t, k, v in filterspec:
16911691
# handle the id prop
1692-
if k == 'id' and nodeid in v:
1692+
if k == 'id':
1693+
if nodeid not in v:
1694+
break
16931695
continue
16941696

1695-
# make sure the node has the property
1696-
if not node.has_key(k):
1697-
# this node doesn't have this property, so reject it
1698-
break
1697+
# get the node value
1698+
nv = node.get(k, None)
1699+
1700+
match = False
16991701

17001702
# now apply the property filter
17011703
if t == LINK:
17021704
# link - if this node's property doesn't appear in the
17031705
# filterspec's nodeid list, skip it
1704-
if node[k] not in v:
1705-
break
1706+
match = nv in v
17061707
elif t == MULTILINK:
17071708
# multilink - if any of the nodeids required by the
17081709
# filterspec aren't in this node's property, then skip
17091710
# it
1710-
have = node[k]
1711-
# check for matching the absence of multilink values
1712-
if not v and have:
1713-
break
1711+
nv = node.get(k, [])
17141712

1715-
# othewise, make sure this node has each of the
1716-
# required values
1717-
for want in v:
1718-
if want not in have:
1719-
break
1713+
# check for matching the absence of multilink values
1714+
if not v:
1715+
match = not nv
17201716
else:
1721-
continue
1722-
break
1717+
# othewise, make sure this node has each of the
1718+
# required values
1719+
for want in v:
1720+
if want not in nv:
1721+
break
1722+
else:
1723+
match = True
17231724
elif t == STRING:
1724-
if node[k] is None:
1725-
break
1725+
if nv is None:
1726+
nv = ''
17261727
# RE search
1727-
if not v.search(node[k]):
1728-
break
1728+
match = v.search(nv)
17291729
elif t == DATE or t == INTERVAL:
1730-
if node[k] is None:
1731-
break
1732-
if v.to_value:
1733-
if not (v.from_value <= node[k] and v.to_value >= node[k]):
1734-
break
1730+
if nv is None:
1731+
match = v is None
17351732
else:
1736-
if not (v.from_value <= node[k]):
1737-
break
1733+
if v.to_value:
1734+
if v.from_value <= nv and v.to_value >= nv:
1735+
match = True
1736+
else:
1737+
if v.from_value <= nv:
1738+
match = True
17381739
elif t == OTHER:
17391740
# straight value comparison for the other types
1740-
if node[k] not in v:
1741-
break
1741+
match = nv in v
1742+
if not match:
1743+
break
17421744
else:
17431745
matches.append([nodeid, node])
17441746

templates/classic/html/query.edit.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
</tal:block>
6161
</tr>
6262

63-
<tr tal:define="queries python:db.query.filter(filterspec={'private_for':uid})"
63+
<tr tal:define="queries python:db.query.filter(filterspec={'creator':uid})"
6464
tal:repeat="query queries">
6565
<td><a tal:attributes="href string:${query/klass}?${query/url}"
6666
tal:content="query/name">query</a></td>
@@ -90,7 +90,7 @@
9090
tal:content="query/name">query</a></td>
9191

9292
<td metal:use-macro="template/macros/include" />
93-
<td colspan="3">[not yours to edit]</td>
93+
<td colspan="3">&nbsp;</td>
9494
</tr>
9595

9696
<tr><td colspan="5">

0 commit comments

Comments
 (0)