changeset 2485:6e8ecdb19e6a maint-0.7

fix anydbm so search for None Link value works... ...also tweak query edit so its a little more useful
author Richard Jones <richard@users.sourceforge.net>
date Mon, 21 Jun 2004 05:42:45 +0000
parents 200eb6e20351
children 9184fbd2aab0
files roundup/backends/back_anydbm.py templates/classic/html/query.edit.html
diffstat 2 files changed, 42 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/roundup/backends/back_anydbm.py	Mon Jun 21 04:56:34 2004 +0000
+++ b/roundup/backends/back_anydbm.py	Mon Jun 21 05:42:45 2004 +0000
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 # 
-#$Id: back_anydbm.py,v 1.146.2.9 2004-06-13 01:11:23 richard Exp $
+#$Id: back_anydbm.py,v 1.146.2.10 2004-06-21 05:42:45 richard Exp $
 '''This module defines a backend that saves the hyperdatabase in a
 database chosen by anydbm. It is guaranteed to always be available in python
 versions >2.1.1 (the dumbdbm fallback in 2.1.1 and earlier has several
@@ -1599,12 +1599,12 @@
         # optimise filterspec
         l = []
         props = self.getprops()
-        LINK = 0
-        MULTILINK = 1
-        STRING = 2
-        DATE = 3
-        INTERVAL = 4
-        OTHER = 6
+        LINK = 'spec:link'
+        MULTILINK = 'spec:multilink'
+        STRING = 'spec:string'
+        DATE = 'spec:date'
+        INTERVAL = 'spec:interval'
+        OTHER = 'spec:other'
         
         timezone = self.db.getUserTimezone()
         for k, v in filterspec.items():
@@ -1689,56 +1689,58 @@
                 # apply filter
                 for t, k, v in filterspec:
                     # handle the id prop
-                    if k == 'id' and nodeid in v:
+                    if k == 'id':
+                        if nodeid not in v:
+                            break
                         continue
 
-                    # make sure the node has the property
-                    if not node.has_key(k):
-                        # this node doesn't have this property, so reject it
-                        break
+                    # get the node value
+                    nv = node.get(k, None)
+
+                    match = False
 
                     # now apply the property filter
                     if t == LINK:
                         # link - if this node's property doesn't appear in the
                         # filterspec's nodeid list, skip it
-                        if node[k] not in v:
-                            break
+                        match = nv in v
                     elif t == MULTILINK:
                         # multilink - if any of the nodeids required by the
                         # filterspec aren't in this node's property, then skip
                         # it
-                        have = node[k]
-                        # check for matching the absence of multilink values
-                        if not v and have:
-                            break
+                        nv = node.get(k, [])
 
-                        # othewise, make sure this node has each of the
-                        # required values
-                        for want in v:
-                            if want not in have:
-                                break
+                        # check for matching the absence of multilink values
+                        if not v:
+                            match = not nv
                         else:
-                            continue
-                        break
+                            # othewise, make sure this node has each of the
+                            # required values
+                            for want in v:
+                                if want not in nv:
+                                    break
+                            else:
+                                match = True
                     elif t == STRING:
-                        if node[k] is None:
-                            break
+                        if nv is None:
+                            nv = ''
                         # RE search
-                        if not v.search(node[k]):
-                            break
+                        match = v.search(nv)
                     elif t == DATE or t == INTERVAL:
-                        if node[k] is None:
-                            break
-                        if v.to_value:
-                            if not (v.from_value <= node[k] and v.to_value >= node[k]):
-                                break
+                        if nv is None:
+                            match = v is None
                         else:
-                            if not (v.from_value <= node[k]):
-                                break
+                            if v.to_value:
+                                if v.from_value <= nv and v.to_value >= nv:
+                                    match = True
+                            else:
+                                if v.from_value <= nv:
+                                    match = True
                     elif t == OTHER:
                         # straight value comparison for the other types
-                        if node[k] not in v:
-                            break
+                        match = nv in v
+                    if not match:
+                        break
                 else:
                     matches.append([nodeid, node])
 
--- a/templates/classic/html/query.edit.html	Mon Jun 21 04:56:34 2004 +0000
+++ b/templates/classic/html/query.edit.html	Mon Jun 21 05:42:45 2004 +0000
@@ -60,7 +60,7 @@
  </tal:block>
 </tr>
 
-<tr tal:define="queries python:db.query.filter(filterspec={'private_for':uid})"
+<tr tal:define="queries python:db.query.filter(filterspec={'creator':uid})"
      tal:repeat="query queries">
  <td><a tal:attributes="href string:${query/klass}?${query/url}"
         tal:content="query/name">query</a></td>
@@ -90,7 +90,7 @@
         tal:content="query/name">query</a></td>
 
  <td metal:use-macro="template/macros/include" />
- <td colspan="3">[not yours to edit]</td>
+ <td colspan="3">&nbsp;</td>
 </tr>
 
 <tr><td colspan="5">

Roundup Issue Tracker: http://roundup-tracker.org/