changeset 51:3a7e5515c1bd

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 :)
author Richard Jones <richard@users.sourceforge.net>
date Mon, 23 Jul 2001 08:45:28 +0000
parents 674bd8e1b36e
children 33bfce110d1e
files roundup-admin roundup/init.py roundup/templates/extended/dbinit.py
diffstat 3 files changed, 45 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/roundup-admin	Mon Jul 23 08:25:33 2001 +0000
+++ b/roundup-admin	Mon Jul 23 08:45:28 2001 +0000
@@ -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 @@
     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 @@
         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 @@
     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 @@
 
 #
 # $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
 #
--- a/roundup/init.py	Mon Jul 23 08:25:33 2001 +0000
+++ b/roundup/init.py	Mon Jul 23 08:45:28 2001 +0000
@@ -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 @@
         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 @@
     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 @@
 
 #
 # $Log: not supported by cvs2svn $
+# Revision 1.2  2001/07/22 12:09:32  richard
+# Final commit of Grande Splite
 #
+#
--- a/roundup/templates/extended/dbinit.py	Mon Jul 23 08:25:33 2001 +0000
+++ b/roundup/templates/extended/dbinit.py	Mon Jul 23 08:45:28 2001 +0000
@@ -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 @@
 
 #
 # $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
 #

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