cubicweb/etwist/twctl.py
changeset 12530 9d88e1177c35
parent 12529 7276f1c89ddd
child 12531 2b9e815d20dc
equal deleted inserted replaced
12529:7276f1c89ddd 12530:9d88e1177c35
     1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
       
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
       
     3 #
       
     4 # This file is part of CubicWeb.
       
     5 #
       
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
       
     7 # terms of the GNU Lesser General Public License as published by the Free
       
     8 # Software Foundation, either version 2.1 of the License, or (at your option)
       
     9 # any later version.
       
    10 #
       
    11 # CubicWeb is distributed in the hope that it will be useful, but WITHOUT
       
    12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
       
    13 # FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
       
    14 # details.
       
    15 #
       
    16 # You should have received a copy of the GNU Lesser General Public License along
       
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
       
    18 """cubicweb-clt handlers for twisted"""
       
    19 
       
    20 from cubicweb.toolsutils import CommandHandler
       
    21 from cubicweb.web.webctl import WebCreateHandler, WebUpgradeHandler
       
    22 from cubicweb.server import serverctl
       
    23 
       
    24 # trigger configuration registration
       
    25 import cubicweb.etwist.twconfig # pylint: disable=W0611
       
    26 
       
    27 class TWCreateHandler(WebCreateHandler):
       
    28     cfgname = 'twisted'
       
    29 
       
    30 class TWStartHandler(CommandHandler):
       
    31     cmdname = 'start'
       
    32     cfgname = 'twisted'
       
    33 
       
    34     def start_server(self, config):
       
    35         from cubicweb.etwist import server
       
    36         return server.run(config)
       
    37 
       
    38 class TWStopHandler(CommandHandler):
       
    39     cmdname = 'stop'
       
    40     cfgname = 'twisted'
       
    41 
       
    42     def poststop(self):
       
    43         pass
       
    44 
       
    45 class TWUpgradeHandler(WebUpgradeHandler):
       
    46     cfgname = 'twisted'
       
    47 
       
    48 
       
    49 class AllInOneCreateHandler(serverctl.RepositoryCreateHandler,
       
    50                             TWCreateHandler):
       
    51     """configuration to get an instance running in a twisted web server
       
    52     integrating a repository server in the same process
       
    53     """
       
    54     cfgname = 'all-in-one'
       
    55 
       
    56     def bootstrap(self, cubes, automatic=False, inputlevel=0):
       
    57         """bootstrap this configuration"""
       
    58         serverctl.RepositoryCreateHandler.bootstrap(self, cubes, automatic, inputlevel)
       
    59         TWCreateHandler.bootstrap(self, cubes, automatic, inputlevel)
       
    60 
       
    61 class AllInOneStartHandler(TWStartHandler):
       
    62     cmdname = 'start'
       
    63     cfgname = 'all-in-one'
       
    64     subcommand = 'cubicweb-twisted'
       
    65 
       
    66 class AllInOneStopHandler(CommandHandler):
       
    67     cmdname = 'stop'
       
    68     cfgname = 'all-in-one'
       
    69     subcommand = 'cubicweb-twisted'
       
    70 
       
    71     def poststop(self):
       
    72         pass
       
    73 
       
    74 class AllInOneUpgradeHandler(TWUpgradeHandler):
       
    75     cfgname = 'all-in-one'