Skip to content

Commit bd5a2b2

Browse files
author
Richard Jones
committed
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 :)
1 parent dc9722b commit bd5a2b2

File tree

3 files changed

+45
-14
lines changed

3 files changed

+45
-14
lines changed

roundup-admin

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /usr/bin/python
22

3-
# $Id: roundup-admin,v 1.2 2001-07-23 08:20:44 richard Exp $
3+
# $Id: roundup-admin,v 1.3 2001-07-23 08:45:28 richard Exp $
44

55
import sys
66
if int(sys.version[0]) < 2:
@@ -34,7 +34,7 @@ def usage(message=''):
3434
if message: message = 'Problem: '+message+'\n'
3535
print '''%sUsage:
3636
37-
roundup [-i instance] init template
37+
roundup [-i instance] init [template backend]
3838
-- initialise the database
3939
roundup [-i instance] spec classname
4040
-- show the properties for a classname
@@ -130,9 +130,6 @@ def main():
130130
n = 3
131131
else:
132132
instance_home = os.environ.get('ROUNDUP_INSTANCE', '')
133-
if not instance_home:
134-
usage('No instance home specified')
135-
return 1
136133

137134
# now figure the command
138135
command = argv[n]
@@ -141,12 +138,30 @@ def main():
141138
if command == 'init':
142139
adminpw = ''
143140
confirm = 'x'
141+
if len(argv) > n:
142+
template = argv[n]
143+
backend = argv[n+1]
144+
else:
145+
template = backend = ''
146+
while not instance_home:
147+
instance_home = raw_input('Enter instance home: ').strip()
148+
# TODO: list the templates
149+
while not template:
150+
template = raw_input('Select template: ').strip()
151+
# TODO: list the backends
152+
while not backend:
153+
backend = raw_input('Select backend: ').strip()
144154
while adminpw != confirm:
145-
adminpw = getpass.getpass('Admin Password:')
146-
confirm = getpass.getpass(' Confirm:')
147-
init.init(instance_home, argv[n], adminpw)
155+
adminpw = getpass.getpass('Admin Password: ')
156+
confirm = getpass.getpass(' Confirm: ')
157+
init.init(instance_home, template, backend, adminpw)
148158
return 0
149159

160+
# from here on, we need an instance_home
161+
if not instance_home:
162+
usage('No instance home specified')
163+
return 1
164+
150165
# get the instance
151166
path, instance = os.path.split(instance_home)
152167
sys.path.insert(0, path)
@@ -277,6 +292,11 @@ if __name__ == '__main__':
277292

278293
#
279294
# $Log: not supported by cvs2svn $
295+
# Revision 1.2 2001/07/23 08:20:44 richard
296+
# Moved over to using marshal in the bsddb and anydbm backends.
297+
# roundup-admin now has a "freshen" command that'll load/save all nodes (not
298+
# retired - mod hyperdb.Class.list() so it lists retired nodes)
299+
#
280300
# Revision 1.1 2001/07/23 03:46:48 richard
281301
# moving the bin files to facilitate out-of-the-boxness
282302
#

roundup/init.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: init.py,v 1.2 2001-07-22 12:09:32 richard Exp $
1+
# $Id: init.py,v 1.3 2001-07-23 08:45:28 richard Exp $
22

33
import os, shutil, sys
44

@@ -31,14 +31,19 @@ def copytree(src, dst, symlinks=0):
3131
else:
3232
shutil.copy2(srcname, dstname)
3333

34-
def init(instance, template, adminpw):
34+
def init(instance, template, backend, adminpw):
3535
''' initialise an instance using the named template
3636
'''
3737
# first, copy the template dir over
3838
template_dir = os.path.split(__file__)[0]
3939
template = os.path.join(template_dir, 'templates', template)
4040
copytree(template, instance)
4141

42+
# now select database
43+
db = '''# WARNING: DO NOT EDIT THIS FILE!!!
44+
from roundup.backends.back_%s import Database'''%backend
45+
open(os.path.join(instance, 'select_db.py'), 'w').write(db)
46+
4247
# now import the instance and call its init
4348
path, instance = os.path.split(instance)
4449
sys.path.insert(0, path)
@@ -47,4 +52,7 @@ def init(instance, template, adminpw):
4752

4853
#
4954
# $Log: not supported by cvs2svn $
55+
# Revision 1.2 2001/07/22 12:09:32 richard
56+
# Final commit of Grande Splite
57+
#
5058
#

roundup/templates/extended/dbinit.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
# $Id: dbinit.py,v 1.3 2001-07-23 07:14:41 richard Exp $
1+
# $Id: dbinit.py,v 1.4 2001-07-23 08:45:28 richard Exp $
22

33
import os
44

55
import instance_config
66
from roundup import roundupdb, cgi_client, mailgw
7-
from roundup.backends import bsddb
7+
import select_db
88
from roundup.roundupdb import Class, FileClass
99

10-
class Database(roundupdb.Database, bsddb.Database):
10+
class Database(roundupdb.Database, select_db.Database):
1111
''' Creates a hybrid database from:
12-
. the BSDDB implementation in backends.bsddb
12+
. the selected database back-end from select_db
1313
. the roundup extensions from roundupdb
1414
'''
1515
pass
@@ -171,6 +171,9 @@ def init(adminpw):
171171

172172
#
173173
# $Log: not supported by cvs2svn $
174+
# Revision 1.3 2001/07/23 07:14:41 richard
175+
# Moved the database backends off into backends.
176+
#
174177
# Revision 1.2 2001/07/23 06:25:50 richard
175178
# relfected the move to roundup/backends
176179
#

0 commit comments

Comments
 (0)