From 6a378c18cc54e10520d0890dee00c5ddb755acf4 Mon Sep 17 00:00:00 2001 From: richard Date: Mon, 23 Jul 2001 08:45:28 +0000 Subject: [PATCH] ok, so now "./roundup-admin init" will ask questions in an attempt to get a workable instance_home set up :) _and_ anydbm has had its first test :) git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@55 57a73879-2fb5-44c3-a270-3262357dd7e2 --- roundup-admin | 36 +++++++++++++++++++++------- roundup/init.py | 12 ++++++++-- roundup/templates/extended/dbinit.py | 11 +++++---- 3 files changed, 45 insertions(+), 14 deletions(-) diff --git a/roundup-admin b/roundup-admin index 16c38ba..df9ca58 100755 --- a/roundup-admin +++ b/roundup-admin @@ -1,6 +1,6 @@ #! /usr/bin/python -# $Id: roundup-admin,v 1.2 2001-07-23 08:20:44 richard Exp $ +# $Id: roundup-admin,v 1.3 2001-07-23 08:45:28 richard Exp $ import sys if int(sys.version[0]) < 2: @@ -34,7 +34,7 @@ def usage(message=''): if message: message = 'Problem: '+message+'\n' print '''%sUsage: - roundup [-i instance] init template + roundup [-i instance] init [template backend] -- initialise the database roundup [-i instance] spec classname -- show the properties for a classname @@ -130,9 +130,6 @@ def main(): n = 3 else: instance_home = os.environ.get('ROUNDUP_INSTANCE', '') - if not instance_home: - usage('No instance home specified') - return 1 # now figure the command command = argv[n] @@ -141,12 +138,30 @@ def main(): if command == 'init': adminpw = '' confirm = 'x' + if len(argv) > n: + template = argv[n] + backend = argv[n+1] + else: + template = backend = '' + while not instance_home: + instance_home = raw_input('Enter instance home: ').strip() + # TODO: list the templates + while not template: + template = raw_input('Select template: ').strip() + # TODO: list the backends + while not backend: + backend = raw_input('Select backend: ').strip() while adminpw != confirm: - adminpw = getpass.getpass('Admin Password:') - confirm = getpass.getpass(' Confirm:') - init.init(instance_home, argv[n], adminpw) + adminpw = getpass.getpass('Admin Password: ') + confirm = getpass.getpass(' Confirm: ') + init.init(instance_home, template, backend, adminpw) return 0 + # from here on, we need an instance_home + if not instance_home: + usage('No instance home specified') + return 1 + # get the instance path, instance = os.path.split(instance_home) sys.path.insert(0, path) @@ -277,6 +292,11 @@ if __name__ == '__main__': # # $Log: not supported by cvs2svn $ +# Revision 1.2 2001/07/23 08:20:44 richard +# Moved over to using marshal in the bsddb and anydbm backends. +# roundup-admin now has a "freshen" command that'll load/save all nodes (not +# retired - mod hyperdb.Class.list() so it lists retired nodes) +# # Revision 1.1 2001/07/23 03:46:48 richard # moving the bin files to facilitate out-of-the-boxness # diff --git a/roundup/init.py b/roundup/init.py index 5e2d31c..d2e39a5 100644 --- a/roundup/init.py +++ b/roundup/init.py @@ -1,4 +1,4 @@ -# $Id: init.py,v 1.2 2001-07-22 12:09:32 richard Exp $ +# $Id: init.py,v 1.3 2001-07-23 08:45:28 richard Exp $ import os, shutil, sys @@ -31,7 +31,7 @@ def copytree(src, dst, symlinks=0): else: shutil.copy2(srcname, dstname) -def init(instance, template, adminpw): +def init(instance, template, backend, adminpw): ''' initialise an instance using the named template ''' # first, copy the template dir over @@ -39,6 +39,11 @@ def init(instance, template, adminpw): template = os.path.join(template_dir, 'templates', template) copytree(template, instance) + # now select database + db = '''# WARNING: DO NOT EDIT THIS FILE!!! +from roundup.backends.back_%s import Database'''%backend + open(os.path.join(instance, 'select_db.py'), 'w').write(db) + # now import the instance and call its init path, instance = os.path.split(instance) sys.path.insert(0, path) @@ -47,4 +52,7 @@ def init(instance, template, adminpw): # # $Log: not supported by cvs2svn $ +# Revision 1.2 2001/07/22 12:09:32 richard +# Final commit of Grande Splite +# # diff --git a/roundup/templates/extended/dbinit.py b/roundup/templates/extended/dbinit.py index 3684693..a677082 100644 --- a/roundup/templates/extended/dbinit.py +++ b/roundup/templates/extended/dbinit.py @@ -1,15 +1,15 @@ -# $Id: dbinit.py,v 1.3 2001-07-23 07:14:41 richard Exp $ +# $Id: dbinit.py,v 1.4 2001-07-23 08:45:28 richard Exp $ import os import instance_config from roundup import roundupdb, cgi_client, mailgw -from roundup.backends import bsddb +import select_db from roundup.roundupdb import Class, FileClass -class Database(roundupdb.Database, bsddb.Database): +class Database(roundupdb.Database, select_db.Database): ''' Creates a hybrid database from: - . the BSDDB implementation in backends.bsddb + . the selected database back-end from select_db . the roundup extensions from roundupdb ''' pass @@ -171,6 +171,9 @@ def init(adminpw): # # $Log: not supported by cvs2svn $ +# Revision 1.3 2001/07/23 07:14:41 richard +# Moved the database backends off into backends. +# # Revision 1.2 2001/07/23 06:25:50 richard # relfected the move to roundup/backends # -- 2.30.2