# HG changeset patch # User Alain Leufroy # Date 1400187915 -7200 # Node ID cdc0b0216da299f3a2ccefa59517e5af6deef51a # Parent 1d648d7f072e61f9a7104c962d66e2d6b90912a7 [cwctl] rewrite wsgi method choices This will help devs to add new choices by adding their callback to WSGI_CHOICES. Note: ``options`` becomes a property because ``wsgichoices()`` should be evaluated at the last-minute. diff -r 1d648d7f072e -r cdc0b0216da2 cwctl.py --- a/cwctl.py Mon Dec 01 11:35:05 2014 +0100 +++ b/cwctl.py Thu May 15 23:05:15 2014 +0200 @@ -1044,19 +1044,30 @@ # WSGI ######### +WSGI_CHOICES = {} +from cubicweb.wsgi import server as stdlib_server +WSGI_CHOICES['stdlib'] = stdlib_server +try: + from cubicweb.wsgi import wz +except ImportError: + pass +else: + WSGI_CHOICES['werkzeug'] = wz + + def wsgichoices(): - try: - from werkzeug import serving - except ImportError: - return ('stdlib',) - return ('stdlib', 'werkzeug') + return tuple(WSGI_CHOICES) + class WSGIStartHandler(InstanceCommand): """Start an interactive wsgi server """ name = 'wsgi' actionverb = 'started' arguments = '' - options = ( + + @property + def options(self): + return ( ("debug", {'short': 'D', 'action': 'store_true', 'default': False, @@ -1083,10 +1094,7 @@ init_cmdline_log_threshold(config, self['loglevel']) assert config.name == 'all-in-one' meth = self['method'] - if meth == 'stdlib': - from cubicweb.wsgi import server - else: - from cubicweb.wsgi import wz as server + server = WSGI_CHOICES[meth] return server.run(config)