comparison roundup-admin @ 294:49be38bb6e9a

admin tool now complains if a "find" is attempted with a non-link property.
author Richard Jones <richard@users.sourceforge.net>
date Tue, 16 Oct 2001 03:48:01 +0000
parents ee7705d7bb06
children e155eca83f40
comparison
equal deleted inserted replaced
293:956a9a86217b 294:49be38bb6e9a
14 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 14 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
15 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" 15 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS"
16 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, 16 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
17 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 17 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
18 # 18 #
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 $
20 20
21 import sys 21 import sys
22 if int(sys.version[0]) < 2: 22 if int(sys.version[0]) < 2:
23 print 'Roundup requires python 2.0 or later.' 23 print 'Roundup requires python 2.0 or later.'
24 sys.exit(1) 24 sys.exit(1)
231 apply(cl.set, (nodeid, ), props) 231 apply(cl.set, (nodeid, ), props)
232 return 0 232 return 0
233 233
234 def do_find(db, args, comma_sep=0): 234 def do_find(db, args, comma_sep=0):
235 '''Usage: find classname propname=value ... 235 '''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.
237 237
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
239 value may be either the nodeid of the linked node, or its key value. 239 value may be either the nodeid of the linked node, or its key value.
240 ''' 240 '''
241 classname = args[0] 241 classname = args[0]
242 cl = db.getclass(classname) 242 cl = db.getclass(classname)
243 243
244 # look up the linked-to class and get the nodeid that has the value 244 # look up the linked-to class and get the nodeid that has the value
245 propname, value = args[1].split('=') 245 propname, value = args[1].split('=')
246 num_re = re.compile('^\d+$') 246 num_re = re.compile('^\d+$')
247 if not num_re.match(value): 247 if not num_re.match(value):
248 propcl = cl.properties[propname].classname 248 propcl = cl.properties[propname]
249 propcl = db.getclass(propcl) 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)
250 value = propcl.lookup(value) 254 value = propcl.lookup(value)
251 255
252 # now do the find 256 # now do the find
253 if comma_sep: 257 if comma_sep:
254 print ','.join(cl.find(**{propname: value})) 258 print ','.join(cl.find(**{propname: value}))
595 if __name__ == '__main__': 599 if __name__ == '__main__':
596 sys.exit(main()) 600 sys.exit(main())
597 601
598 # 602 #
599 # $Log: not supported by cvs2svn $ 603 # $Log: not supported by cvs2svn $
604 # Revision 1.28 2001/10/13 00:07:39 richard
605 # More help in admin tool.
606 #
600 # Revision 1.27 2001/10/11 23:43:04 richard 607 # Revision 1.27 2001/10/11 23:43:04 richard
601 # Implemented the comma-separated printing option in the admin tool. 608 # Implemented the comma-separated printing option in the admin tool.
602 # Fixed a typo (more of a vim-o actually :) in mailgw. 609 # Fixed a typo (more of a vim-o actually :) in mailgw.
603 # 610 #
604 # Revision 1.26 2001/10/11 05:03:51 richard 611 # Revision 1.26 2001/10/11 05:03:51 richard

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