comparison roundup-admin @ 224:ad2c98faec97

using isinstance(blah, Foo) now instead of isFooType
author Richard Jones <richard@users.sourceforge.net>
date Sun, 12 Aug 2001 06:32:36 +0000
parents 18134bffab37
children d7d358408537
comparison
equal deleted inserted replaced
223:5ce5fc22ac6c 224:ad2c98faec97
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.15 2001-08-07 00:24:42 richard Exp $ 19 # $Id: roundup-admin,v 1.16 2001-08-12 06:32:36 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)
172 classname, nodeid = roundupdb.splitDesignator(designator) 172 classname, nodeid = roundupdb.splitDesignator(designator)
173 cl = db.getclass(classname) 173 cl = db.getclass(classname)
174 properties = cl.getprops() 174 properties = cl.getprops()
175 for key, value in props.items(): 175 for key, value in props.items():
176 type = properties[key] 176 type = properties[key]
177 if type.isStringType: 177 if isinstance(type, hyperdb.String):
178 continue 178 continue
179 elif type.isDateType: 179 elif isinstance(type, hyperdb.Date):
180 props[key] = date.Date(value) 180 props[key] = date.Date(value)
181 elif type.isIntervalType: 181 elif isinstance(type, hyperdb.Interval):
182 props[key] = date.Interval(value) 182 props[key] = date.Interval(value)
183 elif type.isLinkType: 183 elif isinstance(type, hyperdb.Link):
184 props[key] = value 184 props[key] = value
185 elif type.isMultilinkType: 185 elif isinstance(type, hyperdb.Multilink):
186 props[key] = value.split(',') 186 props[key] = value.split(',')
187 apply(cl.set, (nodeid, ), props) 187 apply(cl.set, (nodeid, ), props)
188 return 0 188 return 0
189 189
190 def do_find(db, args): 190 def do_find(db, args):
236 props = {} 236 props = {}
237 properties = cl.getprops() 237 properties = cl.getprops()
238 for prop in args[1:]: 238 for prop in args[1:]:
239 key, value = prop.split('=') 239 key, value = prop.split('=')
240 type = properties[key] 240 type = properties[key]
241 if type.isStringType: 241 if isinstance(type, hyperdb.String):
242 props[key] = value 242 props[key] = value
243 elif type.isDateType: 243 elif isinstance(type, hyperdb.Date):
244 props[key] = date.Date(value) 244 props[key] = date.Date(value)
245 elif type.isIntervalType: 245 elif isinstance(type, hyperdb.Interval):
246 props[key] = date.Interval(value) 246 props[key] = date.Interval(value)
247 elif type.isLinkType: 247 elif isinstance(type, hyperdb.Link):
248 props[key] = value 248 props[key] = value
249 elif type.isMultilinkType: 249 elif isinstance(type, hyperdb.Multilink):
250 props[key] = value.split(',') 250 props[key] = value.split(',')
251 print apply(cl.create, (), props) 251 print apply(cl.create, (), props)
252 return 0 252 return 0
253 253
254 def do_list(db, args): 254 def do_list(db, args):
310 # for classname, cl in db.classes.items(): 310 # for classname, cl in db.classes.items():
311 # properties = cl.properties.items() 311 # properties = cl.properties.items()
312 # for nodeid in cl.list(): 312 # for nodeid in cl.list():
313 # node = {} 313 # node = {}
314 # for name, type in properties: 314 # for name, type in properties:
315 # if type.isMultilinkType: 315 # isinstance( if type, hyperdb.Multilink):
316 # node[name] = cl.get(nodeid, name, []) 316 # node[name] = cl.get(nodeid, name, [])
317 # else: 317 # else:
318 # node[name] = cl.get(nodeid, name, None) 318 # node[name] = cl.get(nodeid, name, None)
319 # db.setnode(classname, nodeid, node) 319 # db.setnode(classname, nodeid, node)
320 return 1 320 return 1
420 if __name__ == '__main__': 420 if __name__ == '__main__':
421 sys.exit(main()) 421 sys.exit(main())
422 422
423 # 423 #
424 # $Log: not supported by cvs2svn $ 424 # $Log: not supported by cvs2svn $
425 # Revision 1.15 2001/08/07 00:24:42 richard
426 # stupid typo
427 #
425 # Revision 1.14 2001/08/07 00:15:51 richard 428 # Revision 1.14 2001/08/07 00:15:51 richard
426 # Added the copyright/license notice to (nearly) all files at request of 429 # Added the copyright/license notice to (nearly) all files at request of
427 # Bizar Software. 430 # Bizar Software.
428 # 431 #
429 # Revision 1.13 2001/08/05 07:44:13 richard 432 # Revision 1.13 2001/08/05 07:44:13 richard

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