author | Julien Cristau <julien.cristau@logilab.fr> |
Mon, 29 Jun 2015 16:58:43 +0200 | |
changeset 10463 | 9add9b7f9df7 |
parent 10237 | 1e030b1a5622 |
child 10898 | c96d67251a9d |
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 |
9372
e87a808a4c32
[webctl] Generate static data directory on upgrade (closes #2167873)
Julien Cristau <julien.cristau@logilab.fr>
parents:
7619
diff
changeset
|
25 |
from cubicweb.web.webctl import WebCreateHandler, WebUpgradeHandler |
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 |
|
9372
e87a808a4c32
[webctl] Generate static data directory on upgrade (closes #2167873)
Julien Cristau <julien.cristau@logilab.fr>
parents:
7619
diff
changeset
|
51 |
class TWUpgradeHandler(WebUpgradeHandler): |
e87a808a4c32
[webctl] Generate static data directory on upgrade (closes #2167873)
Julien Cristau <julien.cristau@logilab.fr>
parents:
7619
diff
changeset
|
52 |
cfgname = 'twisted' |
e87a808a4c32
[webctl] Generate static data directory on upgrade (closes #2167873)
Julien Cristau <julien.cristau@logilab.fr>
parents:
7619
diff
changeset
|
53 |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
54 |
|
0 | 55 |
try: |
56 |
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
|
57 |
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
|
58 |
TWCreateHandler): |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2395
diff
changeset
|
59 |
"""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
|
60 |
integrating a repository server in the same process |
0 | 61 |
""" |
62 |
cfgname = 'all-in-one' |
|
63 |
||
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
|
64 |
def bootstrap(self, cubes, automatic=False, inputlevel=0): |
0 | 65 |
"""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
|
66 |
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
|
67 |
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
|
68 |
|
0 | 69 |
class AllInOneStartHandler(TWStartHandler): |
70 |
cmdname = 'start' |
|
71 |
cfgname = 'all-in-one' |
|
72 |
subcommand = 'cubicweb-twisted' |
|
73 |
||
10237
1e030b1a5622
Remove leftover bits from start-repository command, and document its demise
Julien Cristau <julien.cristau@logilab.fr>
parents:
9372
diff
changeset
|
74 |
class AllInOneStopHandler(CommandHandler): |
0 | 75 |
cmdname = 'stop' |
76 |
cfgname = 'all-in-one' |
|
77 |
subcommand = 'cubicweb-twisted' |
|
78 |
||
10237
1e030b1a5622
Remove leftover bits from start-repository command, and document its demise
Julien Cristau <julien.cristau@logilab.fr>
parents:
9372
diff
changeset
|
79 |
def poststop(self): |
1e030b1a5622
Remove leftover bits from start-repository command, and document its demise
Julien Cristau <julien.cristau@logilab.fr>
parents:
9372
diff
changeset
|
80 |
pass |
1e030b1a5622
Remove leftover bits from start-repository command, and document its demise
Julien Cristau <julien.cristau@logilab.fr>
parents:
9372
diff
changeset
|
81 |
|
9372
e87a808a4c32
[webctl] Generate static data directory on upgrade (closes #2167873)
Julien Cristau <julien.cristau@logilab.fr>
parents:
7619
diff
changeset
|
82 |
class AllInOneUpgradeHandler(TWUpgradeHandler): |
e87a808a4c32
[webctl] Generate static data directory on upgrade (closes #2167873)
Julien Cristau <julien.cristau@logilab.fr>
parents:
7619
diff
changeset
|
83 |
cfgname = 'all-in-one' |
e87a808a4c32
[webctl] Generate static data directory on upgrade (closes #2167873)
Julien Cristau <julien.cristau@logilab.fr>
parents:
7619
diff
changeset
|
84 |
|
0 | 85 |
except ImportError: |
86 |
pass |