author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Tue, 15 Sep 2009 16:02:07 +0200 | |
branch | 3.5 |
changeset 3233 | 7ac07c3a9659 |
parent 2657 | de974465d381 |
child 3638 | 648d6dbec630 |
permissions | -rw-r--r-- |
0 | 1 |
"""twisted server configurations: |
2 |
||
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
3 |
* the "twisted" configuration to get a web instance running in a standalone |
0 | 4 |
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
|
5 |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
6 |
* the "all-in-one" configuration to get a web instance running in a twisted |
0 | 7 |
web server integrating a repository server in the same process (only available |
8 |
if the repository part of the software is installed |
|
9 |
||
10 |
:organization: Logilab |
|
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
11 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
0 | 12 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
13 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
0 | 14 |
""" |
15 |
__docformat__ = "restructuredtext en" |
|
16 |
||
17 |
from os.path import join |
|
18 |
||
19 |
from cubicweb.web.webconfig import WebConfiguration, merge_options, Method |
|
20 |
||
21 |
class TwistedConfiguration(WebConfiguration): |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
22 |
"""web instance (in a twisted web server) client of a RQL server""" |
0 | 23 |
name = 'twisted' |
24 |
||
25 |
options = merge_options(( |
|
26 |
# ctl configuration |
|
27 |
('host', |
|
28 |
{'type' : 'string', |
|
29 |
'default': None, |
|
30 |
'help': 'host name if not correctly detectable through gethostname', |
|
31 |
'group': 'main', 'inputlevel': 1, |
|
32 |
}), |
|
33 |
('port', |
|
34 |
{'type' : 'int', |
|
35 |
'default': None, |
|
36 |
'help': 'http server port number (default to 8080)', |
|
37 |
'group': 'main', 'inputlevel': 0, |
|
38 |
}), |
|
39 |
('pid-file', |
|
40 |
{'type' : 'string', |
|
41 |
'default': Method('default_pid_file'), |
|
42 |
'help': 'repository\'s pid file', |
|
43 |
'group': 'main', 'inputlevel': 2, |
|
44 |
}), |
|
45 |
('uid', |
|
46 |
{'type' : 'string', |
|
47 |
'default': None, |
|
48 |
'help': 'if this option is set, use the specified user to start \ |
|
49 |
the repository rather than the user running the command', |
|
136
ff51a18c66a3
ask less questions on instance creation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
0
diff
changeset
|
50 |
'group': 'main', 'inputlevel': (WebConfiguration.mode == 'installed') and 0 or 1, |
0 | 51 |
}), |
52 |
('session-time', |
|
53 |
{'type' : 'int', |
|
54 |
'default': 30*60, |
|
55 |
'help': 'session expiration time, default to 30 minutes', |
|
56 |
'group': 'main', 'inputlevel': 1, |
|
57 |
}), |
|
58 |
('profile', |
|
59 |
{'type' : 'string', |
|
60 |
'default': None, |
|
61 |
'help': 'profile code and use the specified file to store stats if this option is set', |
|
62 |
'group': 'main', 'inputlevel': 2, |
|
63 |
}), |
|
64 |
('pyro-server', |
|
65 |
{'type' : 'yn', |
|
66 |
# 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
|
67 |
'default': False, |
0 | 68 |
'help': 'run a pyro server', |
69 |
'group': 'main', 'inputlevel': 1, |
|
70 |
}), |
|
71 |
) + WebConfiguration.options) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
136
diff
changeset
|
72 |
|
0 | 73 |
def server_file(self): |
74 |
return join(self.apphome, '%s-%s.py' % (self.appid, self.name)) |
|
75 |
||
76 |
def default_base_url(self): |
|
77 |
from socket import gethostname |
|
78 |
return 'http://%s:%s/' % (self['host'] or gethostname(), self['port'] or 8080) |
|
79 |
||
80 |
try: |
|
81 |
from cubicweb.server.serverconfig import ServerConfiguration |
|
82 |
||
83 |
class AllInOneConfiguration(TwistedConfiguration, ServerConfiguration): |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
84 |
"""repository and web instance in the same twisted process""" |
0 | 85 |
name = 'all-in-one' |
86 |
repo_method = 'inmemory' |
|
87 |
options = merge_options(TwistedConfiguration.options |
|
88 |
+ ServerConfiguration.options) |
|
89 |
||
2657
de974465d381
[appobject] kill VObject class, move base selector classes to appobject
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2476
diff
changeset
|
90 |
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
|
91 |
cube_appobject_path = TwistedConfiguration.cube_appobject_path | ServerConfiguration.cube_appobject_path |
0 | 92 |
def pyro_enabled(self): |
93 |
"""tell if pyro is activated for the in memory repository""" |
|
94 |
return self['pyro-server'] |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
136
diff
changeset
|
95 |
|
0 | 96 |
except ImportError: |
97 |
pass |