Separate twisted-specific configuration from WebConfigurationBase class
This is in preparation of dropping the Twisted web server backend.
We thus draw a clearer line between what's specific to twisted from
what's generic by moving WebConfigurationBase class into
cubicweb/web/webconfig.py and only keeping twisted-related in
AllInOneConfiguration (still living in cubicweb/etwist/twconfig.py).
--- a/cubicweb/devtools/__init__.py Thu Mar 21 11:50:31 2019 +0100
+++ b/cubicweb/devtools/__init__.py Thu Mar 21 12:05:30 2019 +0100
@@ -41,7 +41,7 @@
from cubicweb import ExecutionError
from cubicweb import schema, cwconfig
from cubicweb.server.serverconfig import ServerConfiguration
-from cubicweb.etwist.twconfig import WebConfigurationBase
+from cubicweb.web.webconfig import WebConfigurationBase
cwconfig.CubicWebConfiguration.cls_adjust_sys_path()
--- a/cubicweb/etwist/twconfig.py Thu Mar 21 11:50:31 2019 +0100
+++ b/cubicweb/etwist/twconfig.py Thu Mar 21 12:05:30 2019 +0100
@@ -22,39 +22,19 @@
if the repository part of the software is installed
"""
-
from os.path import join
-from logilab.common.configuration import Method, merge_options
+from logilab.common.configuration import merge_options
from cubicweb.cwconfig import CONFIGURATIONS
from cubicweb.server.serverconfig import ServerConfiguration
-from cubicweb.web.webconfig import WebConfiguration
+from cubicweb.web.webconfig import WebConfiguration, WebConfigurationBase
-class WebConfigurationBase(WebConfiguration):
- """web instance (in a twisted web server) client of a RQL server"""
-
+class AllInOneConfiguration(WebConfigurationBase, ServerConfiguration):
+ """repository and web instance in the same twisted process"""
+ name = 'all-in-one'
options = merge_options((
- # ctl configuration
- ('port',
- {'type': 'int',
- 'default': None,
- 'help': 'http server port number (default to 8080)',
- 'group': 'web', 'level': 0,
- }),
- ('interface',
- {'type': 'string',
- 'default': '0.0.0.0',
- 'help': 'http server address on which to listen (default to everywhere)',
- 'group': 'web', 'level': 1,
- }),
- ('max-post-length',
- {'type': 'bytes',
- 'default': '100MB',
- 'help': 'maximum length of HTTP request. Default to 100 MB.',
- 'group': 'web', 'level': 1,
- }),
('profile',
{'type': 'string',
'default': None,
@@ -67,12 +47,6 @@
'help': 'host name if not correctly detectable through gethostname',
'group': 'main', 'level': 1,
}),
- ('pid-file',
- {'type': 'string',
- 'default': Method('default_pid_file'),
- 'help': 'repository\'s pid file',
- 'group': 'main', 'level': 2,
- }),
('uid',
{'type': 'string',
'default': None,
@@ -87,21 +61,8 @@
much greater than connection-poolsize",
'group': 'web', 'level': 3,
}),
- ) + WebConfiguration.options)
-
- def server_file(self):
- return join(self.apphome, '%s-%s.py' % (self.appid, self.name))
-
- def default_base_url(self):
- from socket import getfqdn
- return 'http://%s:%s/' % (self['host'] or getfqdn().lower(), self['port'] or 8080)
-
-
-class AllInOneConfiguration(WebConfigurationBase, ServerConfiguration):
- """repository and web instance in the same twisted process"""
- name = 'all-in-one'
- options = merge_options(WebConfigurationBase.options
- + ServerConfiguration.options)
+ ) + WebConfigurationBase.options + ServerConfiguration.options
+ )
cubicweb_appobject_path = (
WebConfigurationBase.cubicweb_appobject_path
@@ -112,5 +73,8 @@
| ServerConfiguration.cube_appobject_path
)
+ def server_file(self):
+ return join(self.apphome, '%s-%s.py' % (self.appid, self.name))
+
CONFIGURATIONS.append(AllInOneConfiguration)
--- a/cubicweb/web/webconfig.py Thu Mar 21 11:50:31 2019 +0100
+++ b/cubicweb/web/webconfig.py Thu Mar 21 12:05:30 2019 +0100
@@ -29,7 +29,7 @@
from six import text_type
from logilab.common.decorators import cached, cachedproperty
-from logilab.common.configuration import merge_options
+from logilab.common.configuration import Method, merge_options
from cubicweb import ConfigurationError
from cubicweb.cwconfig import CubicWebConfiguration, register_persistent_options
@@ -449,3 +449,39 @@
def static_file_del(self, rpath):
if self.static_file_exists(rpath):
os.remove(join(self.static_directory, rpath))
+
+
+class WebConfigurationBase(WebConfiguration):
+ """web instance (in a web server) client of a RQL server"""
+
+ options = merge_options((
+ # ctl configuration
+ ('port',
+ {'type': 'int',
+ 'default': None,
+ 'help': 'http server port number (default to 8080)',
+ 'group': 'web', 'level': 0,
+ }),
+ ('interface',
+ {'type': 'string',
+ 'default': '0.0.0.0',
+ 'help': 'http server address on which to listen (default to everywhere)',
+ 'group': 'web', 'level': 1,
+ }),
+ ('max-post-length', # XXX specific to "wsgi" server
+ {'type': 'bytes',
+ 'default': '100MB',
+ 'help': 'maximum length of HTTP request. Default to 100 MB.',
+ 'group': 'web', 'level': 1,
+ }),
+ ('pid-file',
+ {'type': 'string',
+ 'default': Method('default_pid_file'),
+ 'help': 'repository\'s pid file',
+ 'group': 'main', 'level': 2,
+ }),
+ ) + WebConfiguration.options)
+
+ def default_base_url(self):
+ from socket import getfqdn
+ return 'http://%s:%s/' % (self['host'] or getfqdn().lower(), self['port'] or 8080)