author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Wed, 05 May 2010 18:54:04 +0200 | |
branch | oldstable |
changeset 5484 | 95f2384b4495 |
parent 5428 | 98e0b7421e51 |
child 5456 | d040889fac4e |
permissions | -rw-r--r-- |
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
|
1 |
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
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 | 18 |
"""twisted server configurations: |
19 |
||
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
20 |
* the "twisted" configuration to get a web instance running in a standalone |
0 | 21 |
twisted web server which talk to a repository server using Pyro |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
136
diff
changeset
|
22 |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
23 |
* the "all-in-one" configuration to get a web instance running in a twisted |
0 | 24 |
web server integrating a repository server in the same process (only available |
25 |
if the repository part of the software is installed |
|
26 |
||
27 |
""" |
|
28 |
__docformat__ = "restructuredtext en" |
|
29 |
||
30 |
from os.path import join |
|
31 |
||
4719
aaed3f813ef8
kill dead/useless code as suggested by pylint
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
32 |
from logilab.common.configuration import Method |
aaed3f813ef8
kill dead/useless code as suggested by pylint
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
33 |
|
aaed3f813ef8
kill dead/useless code as suggested by pylint
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
34 |
from cubicweb.web.webconfig import WebConfiguration, merge_options |
0 | 35 |
|
36 |
class TwistedConfiguration(WebConfiguration): |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
37 |
"""web instance (in a twisted web server) client of a RQL server""" |
0 | 38 |
name = 'twisted' |
39 |
||
40 |
options = merge_options(( |
|
41 |
# ctl configuration |
|
42 |
('host', |
|
43 |
{'type' : 'string', |
|
44 |
'default': None, |
|
45 |
'help': 'host name if not correctly detectable through gethostname', |
|
46 |
'group': 'main', 'inputlevel': 1, |
|
47 |
}), |
|
48 |
('port', |
|
49 |
{'type' : 'int', |
|
50 |
'default': None, |
|
51 |
'help': 'http server port number (default to 8080)', |
|
52 |
'group': 'main', 'inputlevel': 0, |
|
53 |
}), |
|
54 |
('pid-file', |
|
55 |
{'type' : 'string', |
|
56 |
'default': Method('default_pid_file'), |
|
57 |
'help': 'repository\'s pid file', |
|
58 |
'group': 'main', 'inputlevel': 2, |
|
59 |
}), |
|
60 |
('uid', |
|
61 |
{'type' : 'string', |
|
62 |
'default': None, |
|
63 |
'help': 'if this option is set, use the specified user to start \ |
|
64 |
the repository rather than the user running the command', |
|
3638
648d6dbec630
system/user modes + CWDEV instead of installed/dev mixed modes. Fix behaviour when setting CW_MODE explicitly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2657
diff
changeset
|
65 |
'group': 'main', 'inputlevel': WebConfiguration.mode == 'system' |
0 | 66 |
}), |
67 |
('session-time', |
|
5326
0d9054eb3bd1
[config] properly use time type for options representing a time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
68 |
{'type' : 'time', |
0d9054eb3bd1
[config] properly use time type for options representing a time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
69 |
'default': '30min', |
0 | 70 |
'help': 'session expiration time, default to 30 minutes', |
71 |
'group': 'main', 'inputlevel': 1, |
|
72 |
}), |
|
73 |
('profile', |
|
74 |
{'type' : 'string', |
|
75 |
'default': None, |
|
76 |
'help': 'profile code and use the specified file to store stats if this option is set', |
|
5428
98e0b7421e51
move rarely used (imo) settings to inputlevel3 in cwctl create
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5424
diff
changeset
|
77 |
'group': 'main', 'inputlevel': 3, |
0 | 78 |
}), |
79 |
('pyro-server', |
|
80 |
{'type' : 'yn', |
|
81 |
# pyro is only a recommends by default, so don't activate it here |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
136
diff
changeset
|
82 |
'default': False, |
0 | 83 |
'help': 'run a pyro server', |
84 |
'group': 'main', 'inputlevel': 1, |
|
85 |
}), |
|
86 |
) + WebConfiguration.options) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
136
diff
changeset
|
87 |
|
0 | 88 |
def server_file(self): |
89 |
return join(self.apphome, '%s-%s.py' % (self.appid, self.name)) |
|
90 |
||
91 |
def default_base_url(self): |
|
92 |
from socket import gethostname |
|
93 |
return 'http://%s:%s/' % (self['host'] or gethostname(), self['port'] or 8080) |
|
94 |
||
95 |
try: |
|
96 |
from cubicweb.server.serverconfig import ServerConfiguration |
|
97 |
||
98 |
class AllInOneConfiguration(TwistedConfiguration, ServerConfiguration): |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
99 |
"""repository and web instance in the same twisted process""" |
0 | 100 |
name = 'all-in-one' |
101 |
repo_method = 'inmemory' |
|
102 |
options = merge_options(TwistedConfiguration.options |
|
103 |
+ ServerConfiguration.options) |
|
104 |
||
2657
de974465d381
[appobject] kill VObject class, move base selector classes to appobject
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2476
diff
changeset
|
105 |
cubicweb_appobject_path = TwistedConfiguration.cubicweb_appobject_path | ServerConfiguration.cubicweb_appobject_path |
de974465d381
[appobject] kill VObject class, move base selector classes to appobject
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2476
diff
changeset
|
106 |
cube_appobject_path = TwistedConfiguration.cube_appobject_path | ServerConfiguration.cube_appobject_path |
0 | 107 |
def pyro_enabled(self): |
108 |
"""tell if pyro is activated for the in memory repository""" |
|
109 |
return self['pyro-server'] |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
136
diff
changeset
|
110 |
|
0 | 111 |
except ImportError: |
112 |
pass |