author | Denis Laxalde <denis.laxalde@logilab.fr> |
Thu, 24 Oct 2013 09:20:45 +0200 | |
branch | stable |
changeset 9314 | 178791fde195 |
parent 7619 | 0d0344fd5231 |
child 9372 | e87a808a4c32 |
permissions | -rw-r--r-- |
7140
ba51dac1115d
[c-c create] unification of c-c create and its subcommands handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6778
diff
changeset
|
1 |
# copyright 2003-2011 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:
4719
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:
4719
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:
4719
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:
4719
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:
4719
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:
4719
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:
4719
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:
4719
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:
4719
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:
4719
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:
4719
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:
4719
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:
4719
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:
4719
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:
4719
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
5814
51cc4b61f9ae
[repo] fix 'c-c start --loglevel LEVEL' for repository only configuration. Closes #1058269.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5752
diff
changeset
|
18 |
"""cubicweb-clt handlers for twisted""" |
0 | 19 |
|
7619
0d0344fd5231
[etwist] clear ui cache at server startup time. Closes #1806933
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7140
diff
changeset
|
20 |
from os.path import join |
0d0344fd5231
[etwist] clear ui cache at server startup time. Closes #1806933
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7140
diff
changeset
|
21 |
|
0d0344fd5231
[etwist] clear ui cache at server startup time. Closes #1806933
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7140
diff
changeset
|
22 |
from logilab.common.shellutils import rm |
0d0344fd5231
[etwist] clear ui cache at server startup time. Closes #1806933
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7140
diff
changeset
|
23 |
|
0 | 24 |
from cubicweb.toolsutils import CommandHandler |
3820
52cd7432030d
c-c create stopped asking if anonymous access should be activated
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3180
diff
changeset
|
25 |
from cubicweb.web.webctl import WebCreateHandler |
0 | 26 |
|
27 |
# trigger configuration registration |
|
6491
ee9a10b6620e
pylint option update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5814
diff
changeset
|
28 |
import cubicweb.etwist.twconfig # pylint: disable=W0611 |
0 | 29 |
|
3820
52cd7432030d
c-c create stopped asking if anonymous access should be activated
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3180
diff
changeset
|
30 |
class TWCreateHandler(WebCreateHandler): |
52cd7432030d
c-c create stopped asking if anonymous access should be activated
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3180
diff
changeset
|
31 |
cfgname = 'twisted' |
52cd7432030d
c-c create stopped asking if anonymous access should be activated
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3180
diff
changeset
|
32 |
|
0 | 33 |
class TWStartHandler(CommandHandler): |
34 |
cmdname = 'start' |
|
35 |
cfgname = 'twisted' |
|
36 |
||
5442
3ed8afbbdf70
[webconfig] refactor/cleanup debug mode management on startup: simply use config.debugmode instead of debug argument everywhere...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
37 |
def start_server(self, config): |
2654
6512522860aa
[twisted] don't use twistd anymore, all-in-one.py file is needed anymore
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2476
diff
changeset
|
38 |
from cubicweb.etwist import server |
7619
0d0344fd5231
[etwist] clear ui cache at server startup time. Closes #1806933
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7140
diff
changeset
|
39 |
config.info('clear ui caches') |
0d0344fd5231
[etwist] clear ui cache at server startup time. Closes #1806933
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7140
diff
changeset
|
40 |
for cachedir in ('uicache', 'uicachehttps'): |
0d0344fd5231
[etwist] clear ui cache at server startup time. Closes #1806933
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7140
diff
changeset
|
41 |
rm(join(config.appdatahome, cachedir, '*')) |
6778
7dd4835d5198
properly tell we've started an instance (close #1391262)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6491
diff
changeset
|
42 |
return server.run(config) |
0 | 43 |
|
44 |
class TWStopHandler(CommandHandler): |
|
45 |
cmdname = 'stop' |
|
46 |
cfgname = 'twisted' |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
47 |
|
5741
bbef88618fbb
[twctl] add missing poststop method #1058268
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5424
diff
changeset
|
48 |
def poststop(self): |
bbef88618fbb
[twctl] add missing poststop method #1058268
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5424
diff
changeset
|
49 |
pass |
bbef88618fbb
[twctl] add missing poststop method #1058268
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5424
diff
changeset
|
50 |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
51 |
|
0 | 52 |
try: |
53 |
from cubicweb.server import serverctl |
|
3820
52cd7432030d
c-c create stopped asking if anonymous access should be activated
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3180
diff
changeset
|
54 |
class AllInOneCreateHandler(serverctl.RepositoryCreateHandler, |
52cd7432030d
c-c create stopped asking if anonymous access should be activated
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3180
diff
changeset
|
55 |
TWCreateHandler): |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2395
diff
changeset
|
56 |
"""configuration to get an instance running in a twisted web server |
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2395
diff
changeset
|
57 |
integrating a repository server in the same process |
0 | 58 |
""" |
59 |
cfgname = 'all-in-one' |
|
60 |
||
7140
ba51dac1115d
[c-c create] unification of c-c create and its subcommands handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6778
diff
changeset
|
61 |
def bootstrap(self, cubes, automatic=False, inputlevel=0): |
0 | 62 |
"""bootstrap this configuration""" |
7140
ba51dac1115d
[c-c create] unification of c-c create and its subcommands handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6778
diff
changeset
|
63 |
serverctl.RepositoryCreateHandler.bootstrap(self, cubes, automatic, inputlevel) |
ba51dac1115d
[c-c create] unification of c-c create and its subcommands handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6778
diff
changeset
|
64 |
TWCreateHandler.bootstrap(self, cubes, automatic, inputlevel) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
65 |
|
0 | 66 |
class AllInOneStartHandler(TWStartHandler): |
67 |
cmdname = 'start' |
|
68 |
cfgname = 'all-in-one' |
|
69 |
subcommand = 'cubicweb-twisted' |
|
70 |
||
71 |
class AllInOneStopHandler(serverctl.RepositoryStopHandler): |
|
72 |
cmdname = 'stop' |
|
73 |
cfgname = 'all-in-one' |
|
74 |
subcommand = 'cubicweb-twisted' |
|
75 |
||
76 |
except ImportError: |
|
77 |
pass |