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 |
|
23 # trigger configuration registration |
|
24 import cubicweb.etwist.twconfig # pylint: disable=W0611 |
|
25 |
|
26 class TWCreateHandler(WebCreateHandler): |
|
27 cfgname = 'twisted' |
|
28 |
|
29 class TWStartHandler(CommandHandler): |
|
30 cmdname = 'start' |
|
31 cfgname = 'twisted' |
|
32 |
|
33 def start_server(self, config): |
|
34 from cubicweb.etwist import server |
|
35 return server.run(config) |
|
36 |
|
37 class TWStopHandler(CommandHandler): |
|
38 cmdname = 'stop' |
|
39 cfgname = 'twisted' |
|
40 |
|
41 def poststop(self): |
|
42 pass |
|
43 |
|
44 class TWUpgradeHandler(WebUpgradeHandler): |
|
45 cfgname = 'twisted' |
|
46 |
|
47 |
|
48 try: |
|
49 from cubicweb.server import serverctl |
|
50 class AllInOneCreateHandler(serverctl.RepositoryCreateHandler, |
|
51 TWCreateHandler): |
|
52 """configuration to get an instance running in a twisted web server |
|
53 integrating a repository server in the same process |
|
54 """ |
|
55 cfgname = 'all-in-one' |
|
56 |
|
57 def bootstrap(self, cubes, automatic=False, inputlevel=0): |
|
58 """bootstrap this configuration""" |
|
59 serverctl.RepositoryCreateHandler.bootstrap(self, cubes, automatic, inputlevel) |
|
60 TWCreateHandler.bootstrap(self, cubes, automatic, inputlevel) |
|
61 |
|
62 class AllInOneStartHandler(TWStartHandler): |
|
63 cmdname = 'start' |
|
64 cfgname = 'all-in-one' |
|
65 subcommand = 'cubicweb-twisted' |
|
66 |
|
67 class AllInOneStopHandler(CommandHandler): |
|
68 cmdname = 'stop' |
|
69 cfgname = 'all-in-one' |
|
70 subcommand = 'cubicweb-twisted' |
|
71 |
|
72 def poststop(self): |
|
73 pass |
|
74 |
|
75 class AllInOneUpgradeHandler(TWUpgradeHandler): |
|
76 cfgname = 'all-in-one' |
|
77 |
|
78 except ImportError: |
|
79 pass |
|