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 <[EMAIL PROTECTED]>
---
 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/trac/admin/console.py
+++ b/trac/admin/console.py
@@ -464,7 +464,7 @@ Type:  '?' or 'help' for help on commands.
     ## Initenv
     _help_initenv = [('initenv',
                       'Create and initialize a new environment interactively'),
-                     ('initenv <projectname> <db> <repostype> <repospath>',
+                     ('initenv <projectname> <db> <repostype> <repospath> 
[dbwr]',
                       'Create and initialize a new environment from 
arguments')]
 
     def do_initdb(self, line):
@@ -493,6 +493,17 @@ Type:  '?' or 'help' for help on commands.
         prompt = 'Database connection string [%s]> ' % ddb
         returnvals.append(raw_input(prompt).strip() or ddb)
         print
+        print ' Please specify the connection string for database writes.'
+        print ' Leave this empty to use the same database for reads as well as'
+        print ' writes. Use it if you have a replicated database setup, where 
only'
+        print ' one master is able to replicate changes to the slave servers.'
+        print ' Syntax is identical to the normal data. Check the Trac'
+        print ' documentation for the exact connection string syntax.'
+        print
+        ddb = ''
+        prompt = 'Write database connection string [%s]> ' % ddb
+        returnvals.append(raw_input(prompt).strip() or ddb)
+        print
         print ' Please specify the type of version control system,'
         print ' By default, it will be svn.'
         print
@@ -532,20 +543,24 @@ Type:  '?' or 'help' for help on commands.
         arg = arg or [''] # Reset to usual empty in case we popped the only one
         project_name = None
         db_str = None
+        dbwr_str = None
         repository_dir = None
         if len(arg) == 1 and not arg[0]:
             returnvals = self.get_initenv_args()
-            project_name, db_str, repository_type, repository_dir = returnvals
-        elif len(arg) != 4:
+            project_name, db_str, dbwr_str, repository_type, repository_dir = 
returnvals
+        elif len(arg) == 4:
+            project_name, db_str, repository_type, repository_dir = arg[:4]
+        elif len(arg) == 5:
+            project_name, db_str, repository_type, repository_dir, dbwr_str = 
arg[:5]
+        else:
             print 'Wrong number of arguments to initenv: %d' % len(arg)
             return 2
-        else:
-            project_name, db_str, repository_type, repository_dir = arg[:4]
 
         try:
             print 'Creating and Initializing Project'
             options = [
                 ('trac', 'database', db_str),
+                ('trac', 'database_write', dbwr_str),
                 ('trac', 'repository_type', repository_type),
                 ('trac', 'repository_dir', repository_dir),
                 ('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/trac/admin/tests/console-tests.txt
+++ b/trac/admin/tests/console-tests.txt
@@ -10,7 +10,7 @@ help
 initenv
        -- Create and initialize a new environment interactively
 
-initenv <projectname> <db> <repostype> <repospath>
+initenv <projectname> <db> <repostype> <repospath> [dbwr]
        -- Create and initialize a new environment from arguments
 
 hotcopy <backupdir>
-- 
1.5.6


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Trac 
Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/trac-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to