new distinguish repairing/creating from regular start.
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 24 Jul 2009 12:47:47 +0200
changeset 2473 490f88fb99b6
parent 2472 a459a6ab78d0
child 2474 23e8aa37b2df
new distinguish repairing/creating from regular start. use this for #323862: db-check should have a 'force' argument
cwconfig.py
cwctl.py
server/repository.py
server/serverctl.py
--- a/cwconfig.py	Fri Jul 24 12:43:41 2009 +0200
+++ b/cwconfig.py	Fri Jul 24 12:47:47 2009 +0200
@@ -541,6 +541,8 @@
     set_language = True
     # set this to true to avoid false error message while creating an application
     creating = False
+    # set this to true to allow somethings which would'nt be possible
+    repairing = False
 
     options = CubicWebNoAppConfiguration.options + (
         ('log-file',
--- a/cwctl.py	Fri Jul 24 12:43:41 2009 +0200
+++ b/cwctl.py	Fri Jul 24 12:47:47 2009 +0200
@@ -616,7 +616,7 @@
     def upgrade_application(self, appid):
         from logilab.common.changelog import Version
         config = cwcfg.config_for(appid)
-        config.creating = True # notice we're not starting the server
+        config.repairing = True # notice we're not starting the server
         config.verbosity = self.config.verbosity
         try:
             config.set_sources_mode(self.config.ext_sources or ('migration',))
--- a/server/repository.py	Fri Jul 24 12:43:41 2009 +0200
+++ b/server/repository.py	Fri Jul 24 12:47:47 2009 +0200
@@ -220,8 +220,8 @@
         for i in xrange(config['connections-pool-size']):
             self._available_pools.put_nowait(ConnectionsPool(self.sources))
         self._shutting_down = False
-        if not config.creating:
-            # call application level initialisation hooks
+        if not (config.creating or config.repairing):
+            # call instance level initialisation hooks
             self.hm.call_hooks('server_startup', repo=self)
             # register a task to cleanup expired session
             self.looping_task(self.config['session-time']/3.,
@@ -455,7 +455,8 @@
         """return the list of cubes used by this application. This is a
         public method, not requiring a session id.
         """
-        versions = self.get_versions(not self.config.creating)
+        versions = self.get_versions(not (self.config.creating
+                                          or self.config.repairing))
         cubes = list(versions)
         cubes.remove('cubicweb')
         return cubes
--- a/server/serverctl.py	Fri Jul 24 12:43:41 2009 +0200
+++ b/server/serverctl.py	Fri Jul 24 12:47:47 2009 +0200
@@ -692,6 +692,11 @@
           'help': 're-indexes the database for full text search if this \
 option is set to "y" or "yes" (may be long for large database).'}
          ),
+        ("force",
+         {'short': 'f', 'action' : "store_true",
+          'default' : False,
+          'help': 'don\'t check instance is up to date.'}
+         ),
 
         )
 
@@ -699,6 +704,7 @@
         from cubicweb.server.checkintegrity import check
         appid = pop_arg(args, 1, msg="No application specified !")
         config = ServerConfiguration.config_for(appid)
+        config.repairing = self.config.force
         repo, cnx = repo_cnx(config)
         check(repo, cnx,
               self.config.checks, self.config.reindex, self.config.autofix)