|
1 | 1 | #! /usr/bin/python |
2 | | -# $Id: roundup-admin,v 1.9 2001-07-30 03:52:55 richard Exp $ |
| 2 | +# $Id: roundup-admin,v 1.10 2001-07-30 08:12:17 richard Exp $ |
3 | 3 |
|
4 | 4 | import sys |
5 | 5 | if int(sys.version[0]) < 2: |
6 | 6 | print 'Roundup requires python 2.0 or later.' |
7 | 7 | sys.exit(1) |
8 | 8 |
|
9 | | -import string, os, getpass, getopt |
| 9 | +import string, os, getpass, getopt, re |
10 | 10 | from roundup import date, roundupdb, init |
11 | 11 |
|
12 | 12 | def usage(message=''): |
@@ -173,19 +173,25 @@ def do_find(db, args): |
173 | 173 | '''Usage: find classname propname=value ... |
174 | 174 | Find the nodes of the given class with a given property value. |
175 | 175 |
|
176 | | - Find the nodes of the given class with a given property value. |
| 176 | + Find the nodes of the given class with a given property value. The |
| 177 | + value may be either the nodeid of the linked node, or its key value. |
177 | 178 | ''' |
178 | 179 | classname = args[0] |
179 | 180 | cl = db.getclass(classname) |
180 | 181 |
|
181 | 182 | # look up the linked-to class and get the nodeid that has the value |
182 | | - propname, value = args[1:].split('=') |
183 | | - propcl = cl[propname].classname |
184 | | - nodeid = propcl.lookup(value) |
| 183 | + propname, value = args[1].split('=') |
| 184 | + num_re = re.compile('^\d+$') |
| 185 | + if num_re.match(value): |
| 186 | + nodeid = value |
| 187 | + else: |
| 188 | + propcl = cl.properties[propname].classname |
| 189 | + propcl = db.getclass(propcl) |
| 190 | + nodeid = propcl.lookup(value) |
185 | 191 |
|
186 | 192 | # now do the find |
187 | 193 | # TODO: handle the -c option |
188 | | - print cl.find(propname, nodeid) |
| 194 | + print cl.find(**{propname: nodeid}) |
189 | 195 | return 0 |
190 | 196 |
|
191 | 197 | def do_spec(db, args): |
@@ -236,7 +242,6 @@ def do_list(db, args): |
236 | 242 | in order: the key, "name", "title" and then the first property, |
237 | 243 | alphabetically. |
238 | 244 | ''' |
239 | | - db = instance.open() |
240 | 245 | classname = args[0] |
241 | 246 | cl = db.getclass(classname) |
242 | 247 | if len(args) > 1: |
@@ -404,6 +409,9 @@ if __name__ == '__main__': |
404 | 409 |
|
405 | 410 | # |
406 | 411 | # $Log: not supported by cvs2svn $ |
| 412 | +# Revision 1.9 2001/07/30 03:52:55 richard |
| 413 | +# init help now lists templates and backends |
| 414 | +# |
407 | 415 | # Revision 1.8 2001/07/30 02:37:07 richard |
408 | 416 | # Freshen is really broken. Commented out. |
409 | 417 | # |
|
0 commit comments