annotate src/twisted/plugins/libervia_server.py @ 450:41aae13cab2b

browser_side: increase message box height for all characters to fit
author souliane <souliane@mailoo.org>
date Tue, 20 May 2014 07:22:10 +0200
parents 981ed669d3b3
children 1a0cec9b0f1e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
331
06a48d805547 server side: make Libervia a Twisted plugin, and add it the --port argument + add a config file for the port.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
1 #!/usr/bin/python
06a48d805547 server side: make Libervia a Twisted plugin, and add it the --port argument + add a config file for the port.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
06a48d805547 server side: make Libervia a Twisted plugin, and add it the --port argument + add a config file for the port.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
3
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 331
diff changeset
4 # Libervia: a Salut à Toi frontend
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 331
diff changeset
5 # Copyright (C) 2013 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
331
06a48d805547 server side: make Libervia a Twisted plugin, and add it the --port argument + add a config file for the port.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
6
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 331
diff changeset
7 # This program is free software: you can redistribute it and/or modify
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 331
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 331
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 331
diff changeset
10 # (at your option) any later version.
331
06a48d805547 server side: make Libervia a Twisted plugin, and add it the --port argument + add a config file for the port.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
11
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 331
diff changeset
12 # This program is distributed in the hope that it will be useful,
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 331
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 331
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 331
diff changeset
15 # GNU Affero General Public License for more details.
331
06a48d805547 server side: make Libervia a Twisted plugin, and add it the --port argument + add a config file for the port.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
16
339
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 331
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
2067d6241927 fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents: 331
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
331
06a48d805547 server side: make Libervia a Twisted plugin, and add it the --port argument + add a config file for the port.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
19
437
fa3b65b68971 server side: ipdb is used instead of pdb in debug mode
Goffi <goffi@goffi.org>
parents: 433
diff changeset
20 from twisted.internet import defer
fa3b65b68971 server side: ipdb is used instead of pdb in debug mode
Goffi <goffi@goffi.org>
parents: 433
diff changeset
21 if defer.Deferred.debug:
fa3b65b68971 server side: ipdb is used instead of pdb in debug mode
Goffi <goffi@goffi.org>
parents: 433
diff changeset
22 # if we are in debug mode, we want to use ipdb instead of pdb
fa3b65b68971 server side: ipdb is used instead of pdb in debug mode
Goffi <goffi@goffi.org>
parents: 433
diff changeset
23 try:
fa3b65b68971 server side: ipdb is used instead of pdb in debug mode
Goffi <goffi@goffi.org>
parents: 433
diff changeset
24 import ipdb
fa3b65b68971 server side: ipdb is used instead of pdb in debug mode
Goffi <goffi@goffi.org>
parents: 433
diff changeset
25 import pdb
fa3b65b68971 server side: ipdb is used instead of pdb in debug mode
Goffi <goffi@goffi.org>
parents: 433
diff changeset
26 pdb.set_trace = ipdb.set_trace
fa3b65b68971 server side: ipdb is used instead of pdb in debug mode
Goffi <goffi@goffi.org>
parents: 433
diff changeset
27 pdb.post_mortem = ipdb.post_mortem
fa3b65b68971 server side: ipdb is used instead of pdb in debug mode
Goffi <goffi@goffi.org>
parents: 433
diff changeset
28 except ImportError:
fa3b65b68971 server side: ipdb is used instead of pdb in debug mode
Goffi <goffi@goffi.org>
parents: 433
diff changeset
29 pass
fa3b65b68971 server side: ipdb is used instead of pdb in debug mode
Goffi <goffi@goffi.org>
parents: 433
diff changeset
30
438
582c435dab6b server side: new log system is used
Goffi <goffi@goffi.org>
parents: 437
diff changeset
31 # XXX: We need to configure logs before any log method is used, so here is the best place.
449
981ed669d3b3 /!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents: 446
diff changeset
32 from libervia.server.constants import Const as C
443
eca26481176f use of new config module for logs
Goffi <goffi@goffi.org>
parents: 438
diff changeset
33 from sat.core import log_config
eca26481176f use of new config module for logs
Goffi <goffi@goffi.org>
parents: 438
diff changeset
34 log_config.satConfigure(C.LOG_BACKEND_TWISTED, C)
438
582c435dab6b server side: new log system is used
Goffi <goffi@goffi.org>
parents: 437
diff changeset
35
331
06a48d805547 server side: make Libervia a Twisted plugin, and add it the --port argument + add a config file for the port.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
36 from zope.interface import implements
06a48d805547 server side: make Libervia a Twisted plugin, and add it the --port argument + add a config file for the port.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
37
06a48d805547 server side: make Libervia a Twisted plugin, and add it the --port argument + add a config file for the port.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
38 from twisted.python import usage
06a48d805547 server side: make Libervia a Twisted plugin, and add it the --port argument + add a config file for the port.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
39 from twisted.plugin import IPlugin
06a48d805547 server side: make Libervia a Twisted plugin, and add it the --port argument + add a config file for the port.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
40 from twisted.application.service import IServiceMaker
06a48d805547 server side: make Libervia a Twisted plugin, and add it the --port argument + add a config file for the port.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
41
415
fadbba1d793f server_side: added support for SSL and related parameters:
souliane <souliane@mailoo.org>
parents: 360
diff changeset
42 from ConfigParser import SafeConfigParser, NoSectionError, NoOptionError
360
9834136b15ed added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents: 339
diff changeset
43 try:
449
981ed669d3b3 /!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents: 446
diff changeset
44 from libervia.server.server import Libervia
415
fadbba1d793f server_side: added support for SSL and related parameters:
souliane <souliane@mailoo.org>
parents: 360
diff changeset
45 opt_params = Libervia.OPT_PARAMETERS
360
9834136b15ed added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents: 339
diff changeset
46 except (ImportError, SystemExit):
415
fadbba1d793f server_side: added support for SSL and related parameters:
souliane <souliane@mailoo.org>
parents: 360
diff changeset
47 # avoid raising an error when you call twisted and sat is not launched
fadbba1d793f server_side: added support for SSL and related parameters:
souliane <souliane@mailoo.org>
parents: 360
diff changeset
48 opt_params = []
331
06a48d805547 server side: make Libervia a Twisted plugin, and add it the --port argument + add a config file for the port.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
49
06a48d805547 server side: make Libervia a Twisted plugin, and add it the --port argument + add a config file for the port.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
50
06a48d805547 server side: make Libervia a Twisted plugin, and add it the --port argument + add a config file for the port.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
51 class Options(usage.Options):
415
fadbba1d793f server_side: added support for SSL and related parameters:
souliane <souliane@mailoo.org>
parents: 360
diff changeset
52
fadbba1d793f server_side: added support for SSL and related parameters:
souliane <souliane@mailoo.org>
parents: 360
diff changeset
53 # optArgs is not really useful in our case, we need more than a flag
fadbba1d793f server_side: added support for SSL and related parameters:
souliane <souliane@mailoo.org>
parents: 360
diff changeset
54 optParameters = opt_params
fadbba1d793f server_side: added support for SSL and related parameters:
souliane <souliane@mailoo.org>
parents: 360
diff changeset
55
fadbba1d793f server_side: added support for SSL and related parameters:
souliane <souliane@mailoo.org>
parents: 360
diff changeset
56 def __init__(self):
fadbba1d793f server_side: added support for SSL and related parameters:
souliane <souliane@mailoo.org>
parents: 360
diff changeset
57 """You want to read SàT configuration file now in order to overwrite the hard-coded default values.
446
c406e46fe9c0 server_side: update the connection mechanism to handle profile passwords
souliane <souliane@mailoo.org>
parents: 443
diff changeset
58 This is because the priority for the usage of the values is (from lowest to highest):
c406e46fe9c0 server_side: update the connection mechanism to handle profile passwords
souliane <souliane@mailoo.org>
parents: 443
diff changeset
59 - hard-coded default values
c406e46fe9c0 server_side: update the connection mechanism to handle profile passwords
souliane <souliane@mailoo.org>
parents: 443
diff changeset
60 - values from SàT configuration files
c406e46fe9c0 server_side: update the connection mechanism to handle profile passwords
souliane <souliane@mailoo.org>
parents: 443
diff changeset
61 - values passed on the command line
415
fadbba1d793f server_side: added support for SSL and related parameters:
souliane <souliane@mailoo.org>
parents: 360
diff changeset
62 If you do it later: after the command line options have been parsed, there's no good way to know
fadbba1d793f server_side: added support for SSL and related parameters:
souliane <souliane@mailoo.org>
parents: 360
diff changeset
63 if the options values are the hard-coded ones or if they have been passed on the command line.
fadbba1d793f server_side: added support for SSL and related parameters:
souliane <souliane@mailoo.org>
parents: 360
diff changeset
64 """
421
39b07289ff42 server_side: added parameter port_https_ext (external port for HTTPS, used for example for the redirection)
souliane <souliane@mailoo.org>
parents: 417
diff changeset
65 config = SafeConfigParser()
433
bbdbee25123a import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents: 432
diff changeset
66 config.read(C.CONFIG_FILES)
432
8ecc5a7062e4 browser and server sides: fixes module import + use enumerate instead of xrange
souliane <souliane@mailoo.org>
parents: 421
diff changeset
67 for index, param in list(enumerate(self.optParameters)):
8ecc5a7062e4 browser and server sides: fixes module import + use enumerate instead of xrange
souliane <souliane@mailoo.org>
parents: 421
diff changeset
68 # index is only used to not modify the loop variable "param"
8ecc5a7062e4 browser and server sides: fixes module import + use enumerate instead of xrange
souliane <souliane@mailoo.org>
parents: 421
diff changeset
69 name = param[0]
415
fadbba1d793f server_side: added support for SSL and related parameters:
souliane <souliane@mailoo.org>
parents: 360
diff changeset
70 try:
fadbba1d793f server_side: added support for SSL and related parameters:
souliane <souliane@mailoo.org>
parents: 360
diff changeset
71 value = config.get('libervia', name)
432
8ecc5a7062e4 browser and server sides: fixes module import + use enumerate instead of xrange
souliane <souliane@mailoo.org>
parents: 421
diff changeset
72 self.optParameters[index][2] = param[4](value)
415
fadbba1d793f server_side: added support for SSL and related parameters:
souliane <souliane@mailoo.org>
parents: 360
diff changeset
73 except (NoSectionError, NoOptionError):
fadbba1d793f server_side: added support for SSL and related parameters:
souliane <souliane@mailoo.org>
parents: 360
diff changeset
74 pass
fadbba1d793f server_side: added support for SSL and related parameters:
souliane <souliane@mailoo.org>
parents: 360
diff changeset
75 usage.Options.__init__(self)
331
06a48d805547 server side: make Libervia a Twisted plugin, and add it the --port argument + add a config file for the port.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
76
06a48d805547 server side: make Libervia a Twisted plugin, and add it the --port argument + add a config file for the port.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
77
06a48d805547 server side: make Libervia a Twisted plugin, and add it the --port argument + add a config file for the port.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
78 class LiberviaMaker(object):
06a48d805547 server side: make Libervia a Twisted plugin, and add it the --port argument + add a config file for the port.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
79 implements(IServiceMaker, IPlugin)
449
981ed669d3b3 /!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents: 446
diff changeset
80
331
06a48d805547 server side: make Libervia a Twisted plugin, and add it the --port argument + add a config file for the port.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
81 tapname = 'libervia'
449
981ed669d3b3 /!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents: 446
diff changeset
82 # FIXME: twistd bugs when printing 'à' on "Unknown command" error (works on normal command listing)
981ed669d3b3 /!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents: 446
diff changeset
83 description = u'The web frontend of Salut a Toi'
331
06a48d805547 server side: make Libervia a Twisted plugin, and add it the --port argument + add a config file for the port.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
84 options = Options
06a48d805547 server side: make Libervia a Twisted plugin, and add it the --port argument + add a config file for the port.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
85
06a48d805547 server side: make Libervia a Twisted plugin, and add it the --port argument + add a config file for the port.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
86 def makeService(self, options):
416
e9bc7854bce6 server_side: bug fix passing twistd arguments to Libervia
souliane <souliane@mailoo.org>
parents: 415
diff changeset
87 return Libervia(**dict(options)) # get rid of the usage.Option overload
331
06a48d805547 server side: make Libervia a Twisted plugin, and add it the --port argument + add a config file for the port.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
88
06a48d805547 server side: make Libervia a Twisted plugin, and add it the --port argument + add a config file for the port.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
89
421
39b07289ff42 server_side: added parameter port_https_ext (external port for HTTPS, used for example for the redirection)
souliane <souliane@mailoo.org>
parents: 417
diff changeset
90 # affectation to some variable is necessary for twisted introspection to work
331
06a48d805547 server side: make Libervia a Twisted plugin, and add it the --port argument + add a config file for the port.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
91 serviceMaker = LiberviaMaker()
449
981ed669d3b3 /!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents: 446
diff changeset
92