author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Mon, 19 Apr 2010 13:52:55 +0200 | |
changeset 5328 | c51e8f62652a |
parent 5327 | 34a298eca917 |
parent 5326 | 0d9054eb3bd1 |
child 5423 | e15abfdcce38 |
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', |
|
5323
329b4f6d18b4
[config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5270
diff
changeset
|
33 |
'group': 'main', 'level': 1, |
0 | 34 |
}), |
35 |
('port', |
|
36 |
{'type' : 'int', |
|
37 |
'default': None, |
|
38 |
'help': 'http server port number (default to 8080)', |
|
5323
329b4f6d18b4
[config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5270
diff
changeset
|
39 |
'group': 'main', 'level': 0, |
0 | 40 |
}), |
41 |
('pid-file', |
|
42 |
{'type' : 'string', |
|
43 |
'default': Method('default_pid_file'), |
|
44 |
'help': 'repository\'s pid file', |
|
5323
329b4f6d18b4
[config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5270
diff
changeset
|
45 |
'group': 'main', 'level': 2, |
0 | 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', |
|
5323
329b4f6d18b4
[config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5270
diff
changeset
|
52 |
'group': 'main', 'level': WebConfiguration.mode == 'system' |
0 | 53 |
}), |
5270
6297d5265572
[etwist] allow to specify max size for POST request in the configuration. We should deal with this nicely on the js form validation code.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
54 |
('max-post-length', |
5327
34a298eca917
[config] use bytes option type for max post length
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5323
diff
changeset
|
55 |
{'type' : 'bytes', |
34a298eca917
[config] use bytes option type for max post length
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5323
diff
changeset
|
56 |
'default': '100MB', |
34a298eca917
[config] use bytes option type for max post length
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5323
diff
changeset
|
57 |
'help': 'maximum length of HTTP request. Default to 100 MB.', |
5323
329b4f6d18b4
[config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5270
diff
changeset
|
58 |
'group': 'main', 'level': 1, |
0 | 59 |
}), |
60 |
('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
|
61 |
{'type' : 'time', |
0d9054eb3bd1
[config] properly use time type for options representing a time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
62 |
'default': '30min', |
0 | 63 |
'help': 'session expiration time, default to 30 minutes', |
5323
329b4f6d18b4
[config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5270
diff
changeset
|
64 |
'group': 'main', 'level': 1, |
0 | 65 |
}), |
66 |
('profile', |
|
67 |
{'type' : 'string', |
|
68 |
'default': None, |
|
69 |
'help': 'profile code and use the specified file to store stats if this option is set', |
|
5323
329b4f6d18b4
[config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5270
diff
changeset
|
70 |
'group': 'main', 'level': 2, |
0 | 71 |
}), |
72 |
('pyro-server', |
|
73 |
{'type' : 'yn', |
|
74 |
# 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
|
75 |
'default': False, |
0 | 76 |
'help': 'run a pyro server', |
5323
329b4f6d18b4
[config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5270
diff
changeset
|
77 |
'group': 'main', 'level': 1, |
0 | 78 |
}), |
79 |
) + WebConfiguration.options) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
136
diff
changeset
|
80 |
|
0 | 81 |
def server_file(self): |
82 |
return join(self.apphome, '%s-%s.py' % (self.appid, self.name)) |
|
83 |
||
84 |
def default_base_url(self): |
|
85 |
from socket import gethostname |
|
86 |
return 'http://%s:%s/' % (self['host'] or gethostname(), self['port'] or 8080) |
|
87 |
||
88 |
try: |
|
89 |
from cubicweb.server.serverconfig import ServerConfiguration |
|
90 |
||
91 |
class AllInOneConfiguration(TwistedConfiguration, ServerConfiguration): |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
92 |
"""repository and web instance in the same twisted process""" |
0 | 93 |
name = 'all-in-one' |
94 |
repo_method = 'inmemory' |
|
95 |
options = merge_options(TwistedConfiguration.options |
|
96 |
+ ServerConfiguration.options) |
|
97 |
||
2657
de974465d381
[appobject] kill VObject class, move base selector classes to appobject
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2476
diff
changeset
|
98 |
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
|
99 |
cube_appobject_path = TwistedConfiguration.cube_appobject_path | ServerConfiguration.cube_appobject_path |
0 | 100 |
def pyro_enabled(self): |
101 |
"""tell if pyro is activated for the in memory repository""" |
|
102 |
return self['pyro-server'] |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
136
diff
changeset
|
103 |
|
0 | 104 |
except ImportError: |
105 |
pass |