--- a/cwctl.py Wed Mar 16 17:59:10 2016 +0100
+++ b/cwctl.py Tue Apr 12 10:35:06 2016 +0200
@@ -1014,8 +1014,12 @@
# WSGI #########
WSGI_CHOICES = {}
-from cubicweb.wsgi import server as stdlib_server
-WSGI_CHOICES['stdlib'] = stdlib_server
+try:
+ from cubicweb.wsgi import server as stdlib_server
+except ImportError:
+ pass
+else:
+ WSGI_CHOICES['stdlib'] = stdlib_server
try:
from cubicweb.wsgi import wz
except ImportError:
@@ -1033,51 +1037,51 @@
def wsgichoices():
return tuple(WSGI_CHOICES)
-
-class WSGIStartHandler(InstanceCommand):
- """Start an interactive wsgi server """
- name = 'wsgi'
- actionverb = 'started'
- arguments = '<instance>'
+if WSGI_CHOICES:
+ class WSGIStartHandler(InstanceCommand):
+ """Start an interactive wsgi server """
+ name = 'wsgi'
+ actionverb = 'started'
+ arguments = '<instance>'
- @property
- def options(self):
- return (
- ("debug",
- {'short': 'D', 'action': 'store_true',
- 'default': False,
- 'help': 'start server in debug mode.'}),
- ('method',
- {'short': 'm',
- 'type': 'choice',
- 'metavar': '<method>',
- 'default': 'stdlib',
- 'choices': wsgichoices(),
- 'help': 'wsgi utility/method'}),
- ('loglevel',
- {'short': 'l',
- 'type': 'choice',
- 'metavar': '<log level>',
- 'default': None,
- 'choices': ('debug', 'info', 'warning', 'error'),
- 'help': 'debug if -D is set, error otherwise',
- }),
- )
+ @property
+ def options(self):
+ return (
+ ("debug",
+ {'short': 'D', 'action': 'store_true',
+ 'default': False,
+ 'help': 'start server in debug mode.'}),
+ ('method',
+ {'short': 'm',
+ 'type': 'choice',
+ 'metavar': '<method>',
+ 'default': 'stdlib',
+ 'choices': wsgichoices(),
+ 'help': 'wsgi utility/method'}),
+ ('loglevel',
+ {'short': 'l',
+ 'type': 'choice',
+ 'metavar': '<log level>',
+ 'default': None,
+ 'choices': ('debug', 'info', 'warning', 'error'),
+ 'help': 'debug if -D is set, error otherwise',
+ }),
+ )
- def wsgi_instance(self, appid):
- config = cwcfg.config_for(appid, debugmode=self['debug'])
- init_cmdline_log_threshold(config, self['loglevel'])
- assert config.name == 'all-in-one'
- meth = self['method']
- server = WSGI_CHOICES[meth]
- return server.run(config)
+ def wsgi_instance(self, appid):
+ config = cwcfg.config_for(appid, debugmode=self['debug'])
+ init_cmdline_log_threshold(config, self['loglevel'])
+ assert config.name == 'all-in-one'
+ meth = self['method']
+ server = WSGI_CHOICES[meth]
+ return server.run(config)
+ CWCTL.register(WSGIStartHandler)
for cmdcls in (ListCommand,
CreateInstanceCommand, DeleteInstanceCommand,
StartInstanceCommand, StopInstanceCommand, RestartInstanceCommand,
- WSGIStartHandler,
ReloadConfigurationCommand, StatusCommand,
UpgradeInstanceCommand,
ListVersionsInstanceCommand,