author | Stephanie Marcu <stephanie.marcu@logilab.fr> |
Thu, 15 Apr 2010 16:20:53 +0200 | |
branch | stable |
changeset 5286 | 43d7044f8d0b |
parent 4719 | aaed3f813ef8 |
child 5270 | 6297d5265572 |
child 5326 | 0d9054eb3bd1 |
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 |
|
4212
ab6573088b4a
update copyright: welcome 2010
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3638
diff
changeset
|
11 |
:copyright: 2001-2010 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 |
||
4719
aaed3f813ef8
kill dead/useless code as suggested by pylint
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
19 |
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
|
20 |
|
aaed3f813ef8
kill dead/useless code as suggested by pylint
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
21 |
from cubicweb.web.webconfig import WebConfiguration, merge_options |
0 | 22 |
|
23 |
class TwistedConfiguration(WebConfiguration): |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
24 |
"""web instance (in a twisted web server) client of a RQL server""" |
0 | 25 |
name = 'twisted' |
26 |
||
27 |
options = merge_options(( |
|
28 |
# ctl configuration |
|
29 |
('host', |
|
30 |
{'type' : 'string', |
|
31 |
'default': None, |
|
32 |
'help': 'host name if not correctly detectable through gethostname', |
|
33 |
'group': 'main', 'inputlevel': 1, |
|
34 |
}), |
|
35 |
('port', |
|
36 |
{'type' : 'int', |
|
37 |
'default': None, |
|
38 |
'help': 'http server port number (default to 8080)', |
|
39 |
'group': 'main', 'inputlevel': 0, |
|
40 |
}), |
|
41 |
('pid-file', |
|
42 |
{'type' : 'string', |
|
43 |
'default': Method('default_pid_file'), |
|
44 |
'help': 'repository\'s pid file', |
|
45 |
'group': 'main', 'inputlevel': 2, |
|
46 |
}), |
|
47 |
('uid', |
|
48 |
{'type' : 'string', |
|
49 |
'default': None, |
|
50 |
'help': 'if this option is set, use the specified user to start \ |
|
51 |
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
|
52 |
'group': 'main', 'inputlevel': WebConfiguration.mode == 'system' |
0 | 53 |
}), |
54 |
('session-time', |
|
55 |
{'type' : 'int', |
|
56 |
'default': 30*60, |
|
57 |
'help': 'session expiration time, default to 30 minutes', |
|
58 |
'group': 'main', 'inputlevel': 1, |
|
59 |
}), |
|
60 |
('profile', |
|
61 |
{'type' : 'string', |
|
62 |
'default': None, |
|
63 |
'help': 'profile code and use the specified file to store stats if this option is set', |
|
64 |
'group': 'main', 'inputlevel': 2, |
|
65 |
}), |
|
66 |
('pyro-server', |
|
67 |
{'type' : 'yn', |
|
68 |
# 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
|
69 |
'default': False, |
0 | 70 |
'help': 'run a pyro server', |
71 |
'group': 'main', 'inputlevel': 1, |
|
72 |
}), |
|
73 |
) + WebConfiguration.options) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
136
diff
changeset
|
74 |
|
0 | 75 |
def server_file(self): |
76 |
return join(self.apphome, '%s-%s.py' % (self.appid, self.name)) |
|
77 |
||
78 |
def default_base_url(self): |
|
79 |
from socket import gethostname |
|
80 |
return 'http://%s:%s/' % (self['host'] or gethostname(), self['port'] or 8080) |
|
81 |
||
82 |
try: |
|
83 |
from cubicweb.server.serverconfig import ServerConfiguration |
|
84 |
||
85 |
class AllInOneConfiguration(TwistedConfiguration, ServerConfiguration): |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
86 |
"""repository and web instance in the same twisted process""" |
0 | 87 |
name = 'all-in-one' |
88 |
repo_method = 'inmemory' |
|
89 |
options = merge_options(TwistedConfiguration.options |
|
90 |
+ ServerConfiguration.options) |
|
91 |
||
2657
de974465d381
[appobject] kill VObject class, move base selector classes to appobject
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2476
diff
changeset
|
92 |
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
|
93 |
cube_appobject_path = TwistedConfiguration.cube_appobject_path | ServerConfiguration.cube_appobject_path |
0 | 94 |
def pyro_enabled(self): |
95 |
"""tell if pyro is activated for the in memory repository""" |
|
96 |
return self['pyro-server'] |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
136
diff
changeset
|
97 |
|
0 | 98 |
except ImportError: |
99 |
pass |