cubicweb/etwist/twconfig.py
author Denis Laxalde <denis.laxalde@logilab.fr>
Thu, 21 Mar 2019 12:05:30 +0100
changeset 12529 7276f1c89ddd
parent 12527 bcb895aa2684
permissions -rw-r--r--
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).
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10235
684215aca046 Remove remote repository-access-through-pyro support
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 9252
diff changeset
     1
# copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
5421
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5326
diff changeset
     2
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5326
diff changeset
     3
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5326
diff changeset
     4
# This file is part of CubicWeb.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5326
diff changeset
     5
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5326
diff changeset
     6
# CubicWeb is free software: you can redistribute it and/or modify it under the
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5326
diff changeset
     7
# terms of the GNU Lesser General Public License as published by the Free
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5326
diff changeset
     8
# Software Foundation, either version 2.1 of the License, or (at your option)
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5326
diff changeset
     9
# any later version.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5326
diff changeset
    10
#
5424
8ecbcbff9777 replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5421
diff changeset
    11
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT
5421
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5326
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5326
diff changeset
    13
# FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5326
diff changeset
    14
# details.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5326
diff changeset
    15
#
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5326
diff changeset
    16
# You should have received a copy of the GNU Lesser General Public License along
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5326
diff changeset
    17
# with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    18
"""twisted server configurations:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    19
2476
1294a6bdf3bf application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    20
* the "all-in-one" configuration to get a web instance running in a twisted
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    21
  web server integrating a repository server in the same process (only available
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    22
  if the repository part of the software is installed
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    23
"""
11767
432f87a63057 flake8 and all
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 11739
diff changeset
    24
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    25
from os.path import join
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    26
12529
7276f1c89ddd Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12527
diff changeset
    27
from logilab.common.configuration import merge_options
4719
aaed3f813ef8 kill dead/useless code as suggested by pylint
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4212
diff changeset
    28
6844
5ae2bc554c23 [config] stop using a metaclass for registration of "public" configuration, simply do it explicitly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6829
diff changeset
    29
from cubicweb.cwconfig import CONFIGURATIONS
11989
309cf6a2c24f [etwist] Drop try/except around definitions of 'all-in-one' configuration and command handlers
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11767
diff changeset
    30
from cubicweb.server.serverconfig import ServerConfiguration
12529
7276f1c89ddd Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12527
diff changeset
    31
from cubicweb.web.webconfig import WebConfiguration, WebConfigurationBase
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    32
6844
5ae2bc554c23 [config] stop using a metaclass for registration of "public" configuration, simply do it explicitly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6829
diff changeset
    33
12529
7276f1c89ddd Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12527
diff changeset
    34
class AllInOneConfiguration(WebConfigurationBase, ServerConfiguration):
7276f1c89ddd Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12527
diff changeset
    35
    """repository and web instance in the same twisted process"""
7276f1c89ddd Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12527
diff changeset
    36
    name = 'all-in-one'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    37
    options = merge_options((
5554
9b7bdbfee68b [config] move web specific config to the web section of the configuration file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5456
diff changeset
    38
        ('profile',
12527
bcb895aa2684 Flake8 cubicweb/etwist/twconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12376
diff changeset
    39
         {'type': 'string',
5554
9b7bdbfee68b [config] move web specific config to the web section of the configuration file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5456
diff changeset
    40
          'default': None,
9b7bdbfee68b [config] move web specific config to the web section of the configuration file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5456
diff changeset
    41
          'help': 'profile code and use the specified file to store stats if this option is set',
9b7bdbfee68b [config] move web specific config to the web section of the configuration file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5456
diff changeset
    42
          'group': 'web', 'level': 3,
9b7bdbfee68b [config] move web specific config to the web section of the configuration file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5456
diff changeset
    43
          }),
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    44
        ('host',
12527
bcb895aa2684 Flake8 cubicweb/etwist/twconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12376
diff changeset
    45
         {'type': 'string',
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    46
          'default': None,
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    47
          'help': 'host name if not correctly detectable through gethostname',
5323
329b4f6d18b4 [config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5270
diff changeset
    48
          'group': 'main', 'level': 1,
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    49
          }),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    50
        ('uid',
12527
bcb895aa2684 Flake8 cubicweb/etwist/twconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12376
diff changeset
    51
         {'type': 'string',
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    52
          'default': None,
12376
890853079ce3 [cubicweb-ctl] make uid option obvious
Laurent Peuch <cortex@worlddomination.be>
parents: 11989
diff changeset
    53
          'help': 'unix user, if this option is set, use the specified user to start \
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    54
the repository rather than the user running the command',
5323
329b4f6d18b4 [config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5270
diff changeset
    55
          'group': 'main', 'level': WebConfiguration.mode == 'system'
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    56
          }),
7644
7a0914469618 [twisted] add an option to configure twisted's threadpool size
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 6844
diff changeset
    57
        ('webserver-threadpool-size',
7a0914469618 [twisted] add an option to configure twisted's threadpool size
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 6844
diff changeset
    58
         {'type': 'int',
7a0914469618 [twisted] add an option to configure twisted's threadpool size
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 6844
diff changeset
    59
          'default': 4,
7a0914469618 [twisted] add an option to configure twisted's threadpool size
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 6844
diff changeset
    60
          'help': "size of twisted's reactor threadpool. It should probably be not too \
7a0914469618 [twisted] add an option to configure twisted's threadpool size
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 6844
diff changeset
    61
much greater than connection-poolsize",
7a0914469618 [twisted] add an option to configure twisted's threadpool size
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 6844
diff changeset
    62
          'group': 'web', 'level': 3,
7a0914469618 [twisted] add an option to configure twisted's threadpool size
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 6844
diff changeset
    63
          }),
12529
7276f1c89ddd Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12527
diff changeset
    64
    ) + WebConfigurationBase.options + ServerConfiguration.options
7276f1c89ddd Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12527
diff changeset
    65
    )
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    66
12527
bcb895aa2684 Flake8 cubicweb/etwist/twconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12376
diff changeset
    67
    cubicweb_appobject_path = (
bcb895aa2684 Flake8 cubicweb/etwist/twconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12376
diff changeset
    68
        WebConfigurationBase.cubicweb_appobject_path
bcb895aa2684 Flake8 cubicweb/etwist/twconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12376
diff changeset
    69
        | ServerConfiguration.cubicweb_appobject_path
bcb895aa2684 Flake8 cubicweb/etwist/twconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12376
diff changeset
    70
    )
bcb895aa2684 Flake8 cubicweb/etwist/twconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12376
diff changeset
    71
    cube_appobject_path = (
bcb895aa2684 Flake8 cubicweb/etwist/twconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12376
diff changeset
    72
        WebConfigurationBase.cube_appobject_path
bcb895aa2684 Flake8 cubicweb/etwist/twconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12376
diff changeset
    73
        | ServerConfiguration.cube_appobject_path
bcb895aa2684 Flake8 cubicweb/etwist/twconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12376
diff changeset
    74
    )
1802
d628defebc17 delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 136
diff changeset
    75
12529
7276f1c89ddd Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12527
diff changeset
    76
    def server_file(self):
7276f1c89ddd Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12527
diff changeset
    77
        return join(self.apphome, '%s-%s.py' % (self.appid, self.name))
7276f1c89ddd Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 12527
diff changeset
    78
6844
5ae2bc554c23 [config] stop using a metaclass for registration of "public" configuration, simply do it explicitly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6829
diff changeset
    79
11989
309cf6a2c24f [etwist] Drop try/except around definitions of 'all-in-one' configuration and command handlers
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 11767
diff changeset
    80
CONFIGURATIONS.append(AllInOneConfiguration)