backport stable branch 3.5
authorNicolas Chauvat <nicolas.chauvat@logilab.fr>
Tue, 25 Aug 2009 11:45:16 +0200
branch3.5
changeset 2973 46a5a94287fa
parent 2972 23418c13e024 (current diff)
parent 2971 bc0a270622c2 (diff)
child 2974 3dfe497e5afa
backport stable branch
--- a/server/serverctl.py	Tue Aug 25 11:18:41 2009 +0200
+++ b/server/serverctl.py	Tue Aug 25 11:45:16 2009 +0200
@@ -257,12 +257,19 @@
           'help': 'verbose mode: will ask all possible configuration questions',
           }
          ),
+        ('automatic',
+         {'short': 'a', 'type' : 'yn', 'metavar': '<auto>',
+          'default': 'n',
+          'help': 'automatic mode: never ask and use default answer to every question',
+          }
+         ),
         )
     def run(self, args):
         """run the command with its specific arguments"""
         from logilab.common.adbh import get_adv_func_helper
         from indexer import get_indexer
         verbose = self.get('verbose')
+        automatic = self.get('automatic')
         appid = pop_arg(args, msg='No instance specified !')
         config = ServerConfiguration.config_for(appid)
         create_db = self.config.create_db
@@ -277,13 +284,13 @@
             try:
                 if helper.users_support:
                     user = source['db-user']
-                    if not helper.user_exists(cursor, user) and \
-                           ASK.confirm('Create db user %s ?' % user, default_is_yes=False):
+                    if not helper.user_exists(cursor, user) and (automatic or \
+                           ASK.confirm('Create db user %s ?' % user, default_is_yes=False)):
                         helper.create_user(source['db-user'], source['db-password'])
                         print '-> user %s created.' % user
                 dbname = source['db-name']
                 if dbname in helper.list_databases(cursor):
-                    if ASK.confirm('Database %s already exists -- do you want to drop it ?' % dbname):
+                    if automatic or ASK.confirm('Database %s already exists -- do you want to drop it ?' % dbname):
                         cursor.execute('DROP DATABASE %s' % dbname)
                     else:
                         return
@@ -311,7 +318,7 @@
         cnx.commit()
         print '-> database for instance %s created and necessary extensions installed.' % appid
         print
-        if ASK.confirm('Run db-init to initialize the system database ?'):
+        if automatic or ASK.confirm('Run db-init to initialize the system database ?'):
             cmd_run('db-init', config.appid)
         else:
             print ('-> nevermind, you can do it later with '
--- a/web/views/cwuser.py	Tue Aug 25 11:18:41 2009 +0200
+++ b/web/views/cwuser.py	Tue Aug 25 11:45:16 2009 +0200
@@ -11,9 +11,10 @@
 
 from cubicweb.selectors import one_line_rset, implements, match_user_groups
 from cubicweb.view import EntityView
-from cubicweb.web import action
+from cubicweb.web import action, uicfg
 from cubicweb.web.views import primary
 
+uicfg.primaryview_section.tag_attribute(('CWUser', 'login'), 'hidden')
 
 class UserPreferencesEntityAction(action.Action):
     id = 'prefs'