From 918a8a4a1998d88cc6801b7ea4385e9b03e8c2e5 Mon Sep 17 00:00:00 2001
From: Axel Gembe <ago@bastart.eu.org>
Date: Thu, 26 Jun 2008 14:59:16 +0200
Subject: [PATCH 3/3] db: make trac-admin use database_write
Makes the trac-admin utility ask the user for the database write connection
string (default is none) and write it to the generated config file. It also
adds the write database string to the argument list of initenv as the last
argument, making it optional.
Signed-off-by: Axel Gembe <ago@bastart.eu.org>
---
trac/admin/console.py | 25 ++++++++++++++++++++-----
trac/admin/tests/console-tests.txt | 2 +-
2 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/trac/admin/console.py b/trac/admin/console.py
index dc00276..5d3cd5a 100755
|
a
|
b
|
|
| 464 | 464 | ## Initenv |
| 465 | 465 | _help_initenv = [('initenv', |
| 466 | 466 | 'Create and initialize a new environment interactively'), |
| 467 | | ('initenv <projectname> <db> <repostype> <repospath>', |
| | 467 | ('initenv <projectname> <db> <repostype> <repospath> [dbwr]', |
| 468 | 468 | 'Create and initialize a new environment from arguments')] |
| 469 | 469 | |
| 470 | 470 | def do_initdb(self, line): |
| … |
… |
|
| 493 | 493 | prompt = 'Database connection string [%s]> ' % ddb |
| 494 | 494 | returnvals.append(raw_input(prompt).strip() or ddb) |
| 495 | 495 | print |
| | 496 | print ' Please specify the connection string for database writes.' |
| | 497 | print ' Leave this empty to use the same database for reads as well as' |
| | 498 | print ' writes. Use it if you have a replicated database setup, where only' |
| | 499 | print ' one master is able to replicate changes to the slave servers.' |
| | 500 | print ' Syntax is identical to the normal data. Check the Trac' |
| | 501 | print ' documentation for the exact connection string syntax.' |
| | 502 | print |
| | 503 | ddb = '' |
| | 504 | prompt = 'Write database connection string [%s]> ' % ddb |
| | 505 | returnvals.append(raw_input(prompt).strip() or ddb) |
| | 506 | print |
| 496 | 507 | print ' Please specify the type of version control system,' |
| 497 | 508 | print ' By default, it will be svn.' |
| 498 | 509 | print |
| … |
… |
|
| 532 | 543 | arg = arg or [''] # Reset to usual empty in case we popped the only one |
| 533 | 544 | project_name = None |
| 534 | 545 | db_str = None |
| | 546 | dbwr_str = None |
| 535 | 547 | repository_dir = None |
| 536 | 548 | if len(arg) == 1 and not arg[0]: |
| 537 | 549 | returnvals = self.get_initenv_args() |
| 538 | | project_name, db_str, repository_type, repository_dir = returnvals |
| 539 | | elif len(arg) != 4: |
| | 550 | project_name, db_str, dbwr_str, repository_type, repository_dir = returnvals |
| | 551 | elif len(arg) == 4: |
| | 552 | project_name, db_str, repository_type, repository_dir = arg[:4] |
| | 553 | elif len(arg) == 5: |
| | 554 | project_name, db_str, repository_type, repository_dir, dbwr_str = arg[:5] |
| | 555 | else: |
| 540 | 556 | print 'Wrong number of arguments to initenv: %d' % len(arg) |
| 541 | 557 | return 2 |
| 542 | | else: |
| 543 | | project_name, db_str, repository_type, repository_dir = arg[:4] |
| 544 | 558 | |
| 545 | 559 | try: |
| 546 | 560 | print 'Creating and Initializing Project' |
| 547 | 561 | options = [ |
| 548 | 562 | ('trac', 'database', db_str), |
| | 563 | ('trac', 'database_write', dbwr_str), |
| 549 | 564 | ('trac', 'repository_type', repository_type), |
| 550 | 565 | ('trac', 'repository_dir', repository_dir), |
| 551 | 566 | ('project', 'name', project_name), |
diff --git a/trac/admin/tests/console-tests.txt b/trac/admin/tests/console-tests.txt
index 368edcf..2595961 100644
|
a
|
b
|
|
| 10 | 10 | initenv |
| 11 | 11 | -- Create and initialize a new environment interactively |
| 12 | 12 | |
| 13 | | initenv <projectname> <db> <repostype> <repospath> |
| | 13 | initenv <projectname> <db> <repostype> <repospath> [dbwr] |
| 14 | 14 | -- Create and initialize a new environment from arguments |
| 15 | 15 | |
| 16 | 16 | hotcopy <backupdir> |