Mercurial > p > roundup > code
comparison roundup-admin @ 270:a4241ddd22d7
Added the Password property type.
See "pydoc roundup.password" for implementation details. Have updated
some of the documentation too.
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Tue, 09 Oct 2001 07:25:59 +0000 |
| parents | a671e5917b33 |
| children | 79226fbb7741 |
comparison
equal
deleted
inserted
replaced
| 269:82cfd78f3c4e | 270:a4241ddd22d7 |
|---|---|
| 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.21 2001-10-05 02:23:24 richard Exp $ | 19 # $Id: roundup-admin,v 1.22 2001-10-09 07:25:59 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) |
| 25 | 25 |
| 26 import string, os, getpass, getopt, re | 26 import string, os, getpass, getopt, re |
| 27 from roundup import date, roundupdb, init | 27 from roundup import date, roundupdb, init, password |
| 28 import roundup.instance | 28 import roundup.instance |
| 29 | 29 |
| 30 def usage(message=''): | 30 def usage(message=''): |
| 31 if message: message = 'Problem: '+message+'\n' | 31 if message: message = 'Problem: '+message+'\n' |
| 32 commands = [] | 32 commands = [] |
| 178 properties = cl.getprops() | 178 properties = cl.getprops() |
| 179 for key, value in props.items(): | 179 for key, value in props.items(): |
| 180 type = properties[key] | 180 type = properties[key] |
| 181 if isinstance(type, hyperdb.String): | 181 if isinstance(type, hyperdb.String): |
| 182 continue | 182 continue |
| 183 elif isinstance(type, hyperdb.Password): | |
| 184 props[key] = password.Password(value) | |
| 183 elif isinstance(type, hyperdb.Date): | 185 elif isinstance(type, hyperdb.Date): |
| 184 props[key] = date.Date(value) | 186 props[key] = date.Date(value) |
| 185 elif isinstance(type, hyperdb.Interval): | 187 elif isinstance(type, hyperdb.Interval): |
| 186 props[key] = date.Interval(value) | 188 props[key] = date.Interval(value) |
| 187 elif isinstance(type, hyperdb.Link): | 189 elif isinstance(type, hyperdb.Link): |
| 377 if opt == '-h': | 379 if opt == '-h': |
| 378 usage() | 380 usage() |
| 379 return 0 | 381 return 0 |
| 380 if opt == '-i': | 382 if opt == '-i': |
| 381 instance_home = arg | 383 instance_home = arg |
| 382 if opt == '-u': | |
| 383 l = arg.split(':') | |
| 384 name = l[0] | |
| 385 if len(l) > 1: | |
| 386 password = l[1] | |
| 387 if opt == '-c': | 384 if opt == '-c': |
| 388 comma_sep = 1 | 385 comma_sep = 1 |
| 389 | 386 |
| 390 # figure the command | 387 # figure the command |
| 391 if not args: | 388 if not args: |
| 416 | 413 |
| 417 # before we open the db, we may be doing an init | 414 # before we open the db, we may be doing an init |
| 418 if command == 'init': | 415 if command == 'init': |
| 419 return do_init(instance_home, args) | 416 return do_init(instance_home, args) |
| 420 | 417 |
| 421 # open the database | |
| 422 if command in ('create', 'set', 'retire', 'freshen'): | |
| 423 while not name: | |
| 424 name = raw_input('Login name: ') | |
| 425 while not password: | |
| 426 password = getpass.getpass(' password: ') | |
| 427 | |
| 428 # get the instance | |
| 429 instance = roundup.instance.open(instance_home) | |
| 430 | |
| 431 function = figureCommands().get(command, None) | 418 function = figureCommands().get(command, None) |
| 432 | 419 |
| 433 # not a valid command | 420 # not a valid command |
| 434 if function is None: | 421 if function is None: |
| 435 usage('Unknown command "%s"'%command) | 422 usage('Unknown command "%s"'%command) |
| 436 return 1 | 423 return 1 |
| 437 | 424 |
| 438 db = instance.open(name or 'admin') | 425 # get the instance |
| 426 instance = roundup.instance.open(instance_home) | |
| 427 db = instance.open('admin') | |
| 428 | |
| 429 # do the command | |
| 439 try: | 430 try: |
| 440 return function(db, args[1:]) | 431 return function(db, args[1:]) |
| 441 finally: | 432 finally: |
| 442 db.close() | 433 db.close() |
| 443 | 434 |
| 447 if __name__ == '__main__': | 438 if __name__ == '__main__': |
| 448 sys.exit(main()) | 439 sys.exit(main()) |
| 449 | 440 |
| 450 # | 441 # |
| 451 # $Log: not supported by cvs2svn $ | 442 # $Log: not supported by cvs2svn $ |
| 443 # Revision 1.21 2001/10/05 02:23:24 richard | |
| 444 # . roundup-admin create now prompts for property info if none is supplied | |
| 445 # on the command-line. | |
| 446 # . hyperdb Class getprops() method may now return only the mutable | |
| 447 # properties. | |
| 448 # . Login now uses cookies, which makes it a whole lot more flexible. We can | |
| 449 # now support anonymous user access (read-only, unless there's an | |
| 450 # "anonymous" user, in which case write access is permitted). Login | |
| 451 # handling has been moved into cgi_client.Client.main() | |
| 452 # . The "extended" schema is now the default in roundup init. | |
| 453 # . The schemas have had their page headings modified to cope with the new | |
| 454 # login handling. Existing installations should copy the interfaces.py | |
| 455 # file from the roundup lib directory to their instance home. | |
| 456 # . Incorrectly had a Bizar Software copyright on the cgitb.py module from | |
| 457 # Ping - has been removed. | |
| 458 # . Fixed a whole bunch of places in the CGI interface where we should have | |
| 459 # been returning Not Found instead of throwing an exception. | |
| 460 # . Fixed a deviation from the spec: trying to modify the 'id' property of | |
| 461 # an item now throws an exception. | |
| 462 # | |
| 452 # Revision 1.20 2001/10/04 02:12:42 richard | 463 # Revision 1.20 2001/10/04 02:12:42 richard |
| 453 # Added nicer command-line item adding: passing no arguments will enter an | 464 # Added nicer command-line item adding: passing no arguments will enter an |
| 454 # interactive more which asks for each property in turn. While I was at it, I | 465 # interactive more which asks for each property in turn. While I was at it, I |
| 455 # fixed an implementation problem WRT the spec - I wasn't raising a | 466 # fixed an implementation problem WRT the spec - I wasn't raising a |
| 456 # ValueError if the key property was missing from a create(). Also added a | 467 # ValueError if the key property was missing from a create(). Also added a |
