Edgewall Software

Ticket #7392: 0003-db-make-trac-admin-use-database_write.patch

File 0003-db-make-trac-admin-use-database_write.patch, 4.0 KB (added by Axel Gembe, 6 months ago)

[PATCH 3/3] db: make trac-admin use database_write

  • trac/admin/console.py

    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  
    464464    ## Initenv 
    465465    _help_initenv = [('initenv', 
    466466                      'Create and initialize a new environment interactively'), 
    467                      ('initenv <projectname> <db> <repostype> <repospath>', 
     467                     ('initenv <projectname> <db> <repostype> <repospath> [dbwr]', 
    468468                      'Create and initialize a new environment from arguments')] 
    469469 
    470470    def do_initdb(self, line): 
     
    493493        prompt = 'Database connection string [%s]> ' % ddb 
    494494        returnvals.append(raw_input(prompt).strip() or ddb) 
    495495        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 
    496507        print ' Please specify the type of version control system,' 
    497508        print ' By default, it will be svn.' 
    498509        print 
     
    532543        arg = arg or [''] # Reset to usual empty in case we popped the only one 
    533544        project_name = None 
    534545        db_str = None 
     546        dbwr_str = None 
    535547        repository_dir = None 
    536548        if len(arg) == 1 and not arg[0]: 
    537549            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: 
    540556            print 'Wrong number of arguments to initenv: %d' % len(arg) 
    541557            return 2 
    542         else: 
    543             project_name, db_str, repository_type, repository_dir = arg[:4] 
    544558 
    545559        try: 
    546560            print 'Creating and Initializing Project' 
    547561            options = [ 
    548562                ('trac', 'database', db_str), 
     563                ('trac', 'database_write', dbwr_str), 
    549564                ('trac', 'repository_type', repository_type), 
    550565                ('trac', 'repository_dir', repository_dir), 
    551566                ('project', 'name', project_name), 
  • trac/admin/tests/console-tests.txt

    diff --git a/trac/admin/tests/console-tests.txt b/trac/admin/tests/console-tests.txt
    index 368edcf..2595961 100644
    a b  
    1010initenv 
    1111        -- Create and initialize a new environment interactively 
    1212 
    13 initenv <projectname> <db> <repostype> <repospath> 
     13initenv <projectname> <db> <repostype> <repospath> [dbwr] 
    1414        -- Create and initialize a new environment from arguments 
    1515 
    1616hotcopy <backupdir>