ccplugin.py
changeset 11652 e95725d7ce90
parent 11648 9a112017974a
child 11658 a63023a8d457
--- a/ccplugin.py	Wed Jan 21 13:51:33 2015 +0100
+++ b/ccplugin.py	Thu Jun 25 22:57:15 2015 +0200
@@ -15,6 +15,7 @@
 import subprocess
 
 from cubicweb import BadCommandUsage, ExecutionError
+from cubicweb.__pkginfo__ import numversion as cwversion
 from cubicweb.cwconfig import CubicWebConfiguration as cwcfg
 from cubicweb.cwctl import CWCTL, InstanceCommand, init_cmdline_log_threshold
 
@@ -58,7 +59,7 @@
           'help': 'debug if -D is set, error otherwise',
           }),
         ('profile',
-         {'short': 'p', 'action': 'store_true',
+         {'action': 'store_true',
           'default': False,
           'help': 'Enable profiling'}),
         ('profile-output',
@@ -72,6 +73,14 @@
           'help': 'Dump profile stats to ouput every N requests '
                   '(default: 100)'}),
     )
+    if cwversion >= (3, 21, 0):
+        options = PyramidStartHandler.options + (
+        ('param',
+         {'short': 'p', 'type': 'named', 'metavar': 'key1:value1,key2:value2',
+          'default': {},
+          'help': 'override <key> configuration file option with <value>.',
+         }),
+        )
 
     _reloader_environ_key = 'CW_RELOADER_SHOULD_RUN'
     _reloader_filelist_environ_key = 'CW_RELOADER_FILELIST'
@@ -278,7 +287,8 @@
             return self.restart_with_reloader()
 
         cwconfig = cwcfg.config_for(appid, debugmode=debugmode)
-
+        if cwversion >= (3, 21, 0):
+            cwconfig.cmdline_options = self.config.param
         if autoreload:
             _turn_sigterm_into_systemexit()
             self.debug('Running reloading file monitor')
@@ -296,15 +306,14 @@
 
         init_cmdline_log_threshold(cwconfig, self['loglevel'])
 
-        host = cwconfig['interface']
-        port = cwconfig['port'] or 8080
-
         app = wsgi_application_from_cwconfig(
             cwconfig, profile=self['profile'],
             profile_output=self['profile-output'],
             profile_dump_every=self['profile-dump-every']
         )
 
+        host = cwconfig['interface']
+        port = cwconfig['port'] or 8080
         repo = cwconfig.repository()
         try:
             repo.start_looping_tasks()