Skip to content

Commit a339773

Browse files
author
Richard Jones
committed
admin tool now complains if a "find" is attempted with a non-link property.
1 parent 21e22f4 commit a339773

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

roundup-admin

Lines changed: 12 additions & 5 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: roundup-admin,v 1.28 2001-10-13 00:07:39 richard Exp $
19+
# $Id: roundup-admin,v 1.29 2001-10-16 03:48:01 richard Exp $
2020

2121
import sys
2222
if int(sys.version[0]) < 2:
@@ -233,9 +233,9 @@ def do_set(db, args, comma_sep=0):
233233

234234
def do_find(db, args, comma_sep=0):
235235
'''Usage: find classname propname=value ...
236-
Find the nodes of the given class with a given property value.
236+
Find the nodes of the given class with a given link property value.
237237
238-
Find the nodes of the given class with a given property value. The
238+
Find the nodes of the given class with a given link property value. The
239239
value may be either the nodeid of the linked node, or its key value.
240240
'''
241241
classname = args[0]
@@ -245,8 +245,12 @@ def do_find(db, args, comma_sep=0):
245245
propname, value = args[1].split('=')
246246
num_re = re.compile('^\d+$')
247247
if not num_re.match(value):
248-
propcl = cl.properties[propname].classname
249-
propcl = db.getclass(propcl)
248+
propcl = cl.properties[propname]
249+
if (not isinstance(propcl, hyperdb.Link) and not
250+
isinstance(type, hyperdb.Multilink)):
251+
print 'You may only "find" link properties'
252+
return 1
253+
propcl = db.getclass(propcl.classname)
250254
value = propcl.lookup(value)
251255

252256
# now do the find
@@ -597,6 +601,9 @@ if __name__ == '__main__':
597601

598602
#
599603
# $Log: not supported by cvs2svn $
604+
# Revision 1.28 2001/10/13 00:07:39 richard
605+
# More help in admin tool.
606+
#
600607
# Revision 1.27 2001/10/11 23:43:04 richard
601608
# Implemented the comma-separated printing option in the admin tool.
602609
# Fixed a typo (more of a vim-o actually :) in mailgw.

roundup/hyperdb.py

Lines changed: 7 additions & 10 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: hyperdb.py,v 1.25 2001-10-11 00:17:51 richard Exp $
18+
# $Id: hyperdb.py,v 1.26 2001-10-16 03:48:01 richard Exp $
1919

2020
# standard python modules
2121
import cPickle, re, string
@@ -644,15 +644,6 @@ def filter(self, filterspec, sort, group, num_re = re.compile('^\d+$')):
644644
elif t == 2 and not v.search(node[k]):
645645
# RE search
646646
break
647-
# elif t == 3 and node[k][:len(v)] != v:
648-
# # start anchored
649-
# break
650-
# elif t == 4 and node[k][-len(v):] != v:
651-
# # end anchored
652-
# break
653-
# elif t == 5 and node[k].find(v) == -1:
654-
# # substring search
655-
# break
656647
elif t == 6 and node[k] != v:
657648
# straight value comparison for the other types
658649
break
@@ -849,6 +840,12 @@ def Choice(name, *options):
849840

850841
#
851842
# $Log: not supported by cvs2svn $
843+
# Revision 1.25 2001/10/11 00:17:51 richard
844+
# Reverted a change in hyperdb so the default value for missing property
845+
# values in a create() is None and not '' (the empty string.) This obviously
846+
# breaks CSV import/export - the string 'None' will be created in an
847+
# export/import operation.
848+
#
852849
# Revision 1.24 2001/10/10 03:54:57 richard
853850
# Added database importing and exporting through CSV files.
854851
# Uses the csv module from object-craft for exporting if it's available.

0 commit comments

Comments
 (0)