index c167c3cdd501a31fb5623b03ef5c6e619a47e9e7..b4124439ace17d12eb955e8d4edf3535a4e4a941 100644 (file)
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#
-#$Id: back_anydbm.py,v 1.113 2003-03-17 22:03:04 kedder Exp $
+#$Id: back_anydbm.py,v 1.114 2003-03-26 04:56:21 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
The filter must match all properties specificed - but if the
property value to match is a list, any one of the values in the
- list may match for that property to match.
+ list may match for that property to match. Unless the property
+ is a Multilink, in which case the item's property list must
+ match the filterspec list.
'''
cn = self.classname
u = []
link_class = self.db.classes[propclass.classname]
for entry in v:
- if entry == '-1': entry = None
+ # the value -1 is a special "not set" sentinel
+ if entry == '-1':
+ entry = None
elif not num_re.match(entry):
try:
entry = link_class.lookup(entry)
l.append((LINK, k, u))
elif isinstance(propclass, Multilink):
- if type(v) is not type([]):
+ # the value -1 is a special "not set" sentinel
+ if v == '-1':
+ v = []
+ elif type(v) is not type([]):
v = [v]
+
# replace key values with node ids
u = []
link_class = self.db.classes[propclass.classname]
raise ValueError, 'new property "%s": %s not a %s'%(
k, entry, self.properties[k].classname)
u.append(entry)
+ u.sort()
l.append((MULTILINK, k, u))
elif isinstance(propclass, String) and k != 'id':
# simple glob searching
# 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
+
+ # othewise, make sure this node has each of the
+ # required values
for want in v:
if want not in have:
break