merge stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 13 Nov 2009 09:16:28 +0100
branchstable
changeset 3837 0cb409871d42
parent 3836 58c09f21f503 (diff)
parent 3834 e3e64352063d (current diff)
child 3838 9cc134372bf8
child 3839 84c9aab84d8c
merge
--- a/server/migractions.py	Thu Nov 12 18:27:59 2009 +0100
+++ b/server/migractions.py	Fri Nov 13 09:16:28 2009 +0100
@@ -526,10 +526,17 @@
                 sourcescfg[cube] = ask_source_config(cube)
                 self.config.write_sources_file(sourcescfg)
                 clear_cache(self.config, 'read_sources_file')
+            # ensure added cube is in config cubes
+            # XXX worth restoring on error?
+            if not cube in self.config._cubes:
+                self.config._cubes += (cube,)
         if not update_database:
             self.commit()
             return
         newcubes_schema = self.config.load_schema(construction_mode='non-strict')
+        # XXX we have to replace fs_schema, used in cmd_add_relation_type
+        # etc. and fsschema of migration script contexts
+        self.fs_schema = self._create_context()['fsschema'] = newcubes_schema
         new = set()
         # execute pre-create files
         for pack in reversed(newcubes):
--- a/server/serverconfig.py	Thu Nov 12 18:27:59 2009 +0100
+++ b/server/serverconfig.py	Fri Nov 13 09:16:28 2009 +0100
@@ -10,7 +10,7 @@
 import os
 from os.path import join, exists
 
-from logilab.common.configuration import REQUIRED, Method, Configuration, \
+from logilab.common.configuration import Method, Configuration, \
      ini_format_section
 from logilab.common.decorators import wproperty, cached, clear_cache
 
@@ -22,7 +22,7 @@
 
 USER_OPTIONS =  (
     ('login', {'type' : 'string',
-               'default': REQUIRED,
+               'default': 'admin',
                'help': "cubicweb manager account's login "
                '(this user will be created)',
                'inputlevel': 0,
--- a/server/serverctl.py	Thu Nov 12 18:27:59 2009 +0100
+++ b/server/serverctl.py	Fri Nov 13 09:16:28 2009 +0100
@@ -133,6 +133,9 @@
             config.input_config('pyro', inputlevel)
         print '\n'+underline_title('Configuring the sources')
         sourcesfile = config.sources_file()
+        # XXX hack to make Method('default_instance_id') usable in db option
+        # defs (in native.py)
+        Configuration.default_instance_id = staticmethod(lambda: config.appid)
         sconfig = Configuration(options=SOURCE_TYPES['native'].options)
         sconfig.adapter = 'native'
         sconfig.input_config(inputlevel=inputlevel)
--- a/server/sources/native.py	Thu Nov 12 18:27:59 2009 +0100
+++ b/server/sources/native.py	Fri Nov 13 09:16:28 2009 +0100
@@ -18,12 +18,14 @@
 from base64 import b64decode, b64encode
 
 from logilab.common.cache import Cache
-from logilab.common.configuration import REQUIRED
+from logilab.common.configuration import Method
 from logilab.common.adbh import get_adv_func_helper
+from logilab.common.shellutils import getlogin
 
 from indexer import get_indexer
 
 from cubicweb import UnknownEid, AuthenticationError, Binary, server
+from cubicweb.cwconfig import CubicWebNoAppConfiguration
 from cubicweb.server.utils import crypt_password
 from cubicweb.server.sqlutils import SQL_PREFIX, SQLAdapterMixIn
 from cubicweb.server.rqlannotation import set_qdata
@@ -120,13 +122,13 @@
           }),
         ('db-name',
          {'type' : 'string',
-          'default': REQUIRED,
+          'default': Method('default_instance_id'),
           'help': 'database name',
           'group': 'native-source', 'inputlevel': 0,
           }),
         ('db-user',
          {'type' : 'string',
-          'default': 'cubicweb',
+          'default': CubicWebNoAppConfiguration.mode == 'user' and getlogin() or 'cubicweb',
           'help': 'database user',
           'group': 'native-source', 'inputlevel': 0,
           }),