comparison roundup-admin @ 318:e18dd7227780

Re-enabled login and registration access... ...after lopping them off via disabling access for anonymous users. Major re-org of the htmltemplate code, cleaning it up significantly. Fixed a couple of bugs while I was there. Probably introduced a couple, but things seem to work OK at the moment.
author Richard Jones <richard@users.sourceforge.net>
date Tue, 23 Oct 2001 01:00:18 +0000
parents e32af1eff4ea
children f90abe9e811d
comparison
equal deleted inserted replaced
317:6ce3af6a08ca 318:e18dd7227780
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.36 2001-10-21 00:45:15 richard Exp $ 19 # $Id: roundup-admin,v 1.37 2001-10-23 01:00:18 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)
33 33
34 class AdminTool: 34 class AdminTool:
35 35
36 def __init__(self): 36 def __init__(self):
37 self.commands = {} 37 self.commands = {}
38 for k, v in AdminTool.__dict__.items(): 38 for k in AdminTool.__dict__.keys():
39 if k[:3] == 'do_': 39 if k[:3] == 'do_':
40 self.commands[k[3:]] = v 40 self.commands[k[3:]] = getattr(self, k)
41 self.help = {} 41 self.help = {}
42 for k, v in AdminTool.__dict__.items(): 42 for k in AdminTool.__dict__.keys():
43 if k[:5] == 'help_': 43 if k[:5] == 'help_':
44 self.help[k[5:]] = v 44 self.help[k[5:]] = getattr(self, k)
45 45
46 def usage(message=''): 46 def usage(message=''):
47 if message: message = 'Problem: '+message+'\n' 47 if message: message = 'Problem: '+message+'\n'
48 print '''%sUsage: roundup-admin [-i instance home] [-u login] [-c] <command> <arguments> 48 print '''%sUsage: roundup-admin [-i instance home] [-u login] [-c] <command> <arguments>
49 49
131 initopts -- init command options 131 initopts -- init command options
132 all -- all available help 132 all -- all available help
133 ''' 133 '''
134 help = self.help.get(args[0], None) 134 help = self.help.get(args[0], None)
135 if help: 135 if help:
136 help(self) 136 help()
137 return 137 return
138 help = self.commands.get(args[0], None) 138 help = self.commands.get(args[0], None)
139 if help: 139 if help:
140 # display the help, removing the docsring indent 140 # display the help, removing the docsring indent
141 lines = nl_re.split(help.__doc__) 141 lines = nl_re.split(help.__doc__)
210 ''' 210 '''
211 propname = args[0] 211 propname = args[0]
212 designators = string.split(args[1], ',') 212 designators = string.split(args[1], ',')
213 l = [] 213 l = []
214 for designator in designators: 214 for designator in designators:
215 classname, nodeid = roundupdb.splitDesignator(designator) 215 try:
216 classname, nodeid = roundupdb.splitDesignator(designator)
217 except roundupdb.DesignatorError, message:
218 print 'Error: %s'%message
219 return 1
216 if self.comma_sep: 220 if self.comma_sep:
217 l.append(self.db.getclass(classname).get(nodeid, propname)) 221 l.append(self.db.getclass(classname).get(nodeid, propname))
218 else: 222 else:
219 print self.db.getclass(classname).get(nodeid, propname) 223 print self.db.getclass(classname).get(nodeid, propname)
220 if self.comma_sep: 224 if self.comma_sep:
234 props = {} 238 props = {}
235 for prop in args[1:]: 239 for prop in args[1:]:
236 key, value = prop.split('=') 240 key, value = prop.split('=')
237 props[key] = value 241 props[key] = value
238 for designator in designators: 242 for designator in designators:
239 classname, nodeid = roundupdb.splitDesignator(designator) 243 try:
244 classname, nodeid = roundupdb.splitDesignator(designator)
245 except roundupdb.DesignatorError, message:
246 print 'Error: %s'%message
247 return 1
240 cl = self.db.getclass(classname) 248 cl = self.db.getclass(classname)
241 properties = cl.getprops() 249 properties = cl.getprops()
242 for key, value in props.items(): 250 for key, value in props.items():
243 type = properties[key] 251 type = properties[key]
244 if isinstance(type, hyperdb.String): 252 if isinstance(type, hyperdb.String):
425 '''Usage: history designator 433 '''Usage: history designator
426 Show the history entries of a designator. 434 Show the history entries of a designator.
427 435
428 Lists the journal entries for the node identified by the designator. 436 Lists the journal entries for the node identified by the designator.
429 ''' 437 '''
430 classname, nodeid = roundupdb.splitDesignator(args[0]) 438 try:
439 classname, nodeid = roundupdb.splitDesignator(args[0])
440 except roundupdb.DesignatorError, message:
441 print 'Error: %s'%message
442 return 1
431 # TODO: handle the -c option? 443 # TODO: handle the -c option?
432 print self.db.getclass(classname).history(nodeid) 444 print self.db.getclass(classname).history(nodeid)
433 return 0 445 return 0
434 446
435 def do_retire(self, args): 447 def do_retire(self, args):
439 This action indicates that a particular node is not to be retrieved by 451 This action indicates that a particular node is not to be retrieved by
440 the list or find commands, and its key value may be re-used. 452 the list or find commands, and its key value may be re-used.
441 ''' 453 '''
442 designators = string.split(args[0], ',') 454 designators = string.split(args[0], ',')
443 for designator in designators: 455 for designator in designators:
444 classname, nodeid = roundupdb.splitDesignator(designator) 456 try:
457 classname, nodeid = roundupdb.splitDesignator(designator)
458 except roundupdb.DesignatorError, message:
459 print 'Error: %s'%message
460 return 1
445 self.db.getclass(classname).retire(nodeid) 461 self.db.getclass(classname).retire(nodeid)
446 return 0 462 return 0
447 463
448 def do_export(self, args): 464 def do_export(self, args):
449 '''Usage: export class[,class] destination_dir 465 '''Usage: export class[,class] destination_dir
608 print function.__doc__ 624 print function.__doc__
609 return 1 625 return 1
610 626
611 # do the command 627 # do the command
612 try: 628 try:
613 return function(self, args[1:]) 629 return function(args[1:])
614 finally: 630 finally:
615 self.db.close() 631 self.db.close()
616 632
617 return 1 633 return 1
618 634
669 tool = AdminTool() 685 tool = AdminTool()
670 sys.exit(tool.main()) 686 sys.exit(tool.main())
671 687
672 # 688 #
673 # $Log: not supported by cvs2svn $ 689 # $Log: not supported by cvs2svn $
690 # Revision 1.36 2001/10/21 00:45:15 richard
691 # Added author identification to e-mail messages from roundup.
692 #
674 # Revision 1.35 2001/10/20 11:58:48 richard 693 # Revision 1.35 2001/10/20 11:58:48 richard
675 # Catch errors in login - no username or password supplied. 694 # Catch errors in login - no username or password supplied.
676 # Fixed editing of password (Password property type) thanks Roch'e Compaan. 695 # Fixed editing of password (Password property type) thanks Roch'e Compaan.
677 # 696 #
678 # Revision 1.34 2001/10/18 02:16:42 richard 697 # Revision 1.34 2001/10/18 02:16:42 richard

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