author | Laurent Peuch <cortex@worlddomination.be> |
Fri, 27 Sep 2019 07:00:51 +0200 | |
changeset 12776 | 3cbcbaead477 |
parent 12584 | 6eba53763482 |
permissions | -rw-r--r-- |
8601
1a6000ff2080
[web] add a ``anonymize-jsonp-queries`` option in file configuration (closes #2465388)
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
8475
diff
changeset
|
1 |
# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
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
|
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/>. |
5933
3d707b8f8a4d
[web configuration] ensure data home directory / uicache file belong to daemon user and are writeable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5907
diff
changeset
|
18 |
"""web ui configuration for cubicweb instances""" |
0 | 19 |
|
11767
432f87a63057
flake8 and all
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
11461
diff
changeset
|
20 |
|
10666
7f6b5f023884
[py3k] replace '_ = unicode' in global scope (closes #7589459)
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10614
diff
changeset
|
21 |
from cubicweb import _ |
0 | 22 |
|
23 |
import os |
|
8605
797fc2e2fb78
[web] add a digital signature to error form (closes #2522526)
David Douard <david.douard@logilab.fr>
parents:
8601
diff
changeset
|
24 |
import hmac |
797fc2e2fb78
[web] add a digital signature to error form (closes #2522526)
David Douard <david.douard@logilab.fr>
parents:
8601
diff
changeset
|
25 |
from uuid import uuid4 |
12268
d84bc85f7f70
[config] Avoid relying on shared_dir method when possible
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12019
diff
changeset
|
26 |
from os.path import dirname, join, exists, split, isdir |
0 | 27 |
|
8605
797fc2e2fb78
[web] add a digital signature to error form (closes #2522526)
David Douard <david.douard@logilab.fr>
parents:
8601
diff
changeset
|
28 |
from logilab.common.decorators import cached, cachedproperty |
12529
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
29 |
from logilab.common.configuration import Method, merge_options |
0 | 30 |
|
7770
a17145243e04
[session] enforce coherency of login/passwd couple values when no anonymous user (closes: #1910849)
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
7380
diff
changeset
|
31 |
from cubicweb import ConfigurationError |
8989
8742f4bf029f
import merge_options directly from logilab.common
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
8941
diff
changeset
|
32 |
from cubicweb.cwconfig import CubicWebConfiguration, register_persistent_options |
0 | 33 |
|
34 |
||
12268
d84bc85f7f70
[config] Avoid relying on shared_dir method when possible
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12019
diff
changeset
|
35 |
_DATA_DIR = join(dirname(__file__), 'data') |
d84bc85f7f70
[config] Avoid relying on shared_dir method when possible
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12019
diff
changeset
|
36 |
|
d84bc85f7f70
[config] Avoid relying on shared_dir method when possible
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12019
diff
changeset
|
37 |
|
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
38 |
register_persistent_options(( |
0 | 39 |
# site-wide only web ui configuration |
40 |
('site-title', |
|
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
41 |
{'type': 'string', 'default': 'unset title', |
0 | 42 |
'help': _('site title'), |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
43 |
'sitewide': True, 'group': 'ui', |
0 | 44 |
}), |
45 |
('main-template', |
|
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
46 |
{'type': 'string', 'default': 'main-template', |
0 | 47 |
'help': _('id of main template used to render pages'), |
48 |
'sitewide': True, 'group': 'ui', |
|
49 |
}), |
|
50 |
# user web ui configuration |
|
51 |
('fckeditor', |
|
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
52 |
{'type': 'yn', 'default': False, |
0 | 53 |
'help': _('should html fields being edited using fckeditor (a HTML ' |
54 |
'WYSIWYG editor). You should also select text/html as default ' |
|
55 |
'text format to actually get fckeditor.'), |
|
56 |
'group': 'ui', |
|
57 |
}), |
|
58 |
# navigation configuration |
|
59 |
('page-size', |
|
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
60 |
{'type': 'int', 'default': 40, |
0 | 61 |
'help': _('maximum number of objects displayed by page of results'), |
62 |
'group': 'navigation', |
|
63 |
}), |
|
64 |
('related-limit', |
|
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
65 |
{'type': 'int', 'default': 8, |
0 | 66 |
'help': _('maximum number of related entities to display in the primary ' |
67 |
'view'), |
|
68 |
'group': 'navigation', |
|
69 |
}), |
|
70 |
('combobox-limit', |
|
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
71 |
{'type': 'int', 'default': 20, |
0 | 72 |
'help': _('maximum number of entities to display in related combo box'), |
73 |
'group': 'navigation', |
|
74 |
}), |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
75 |
|
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
76 |
)) |
0 | 77 |
|
78 |
||
12019
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
79 |
class BaseWebConfiguration(CubicWebConfiguration): |
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
80 |
"""Base class for web configurations""" |
11900
8496135b6dc1
[cwvreg] load registry using modules names instead of directories
Philippe Pepiot <philippe.pepiot@logilab.fr>
parents:
11794
diff
changeset
|
81 |
cubicweb_appobject_path = CubicWebConfiguration.cubicweb_appobject_path | set(['web.views']) |
2657
de974465d381
[appobject] kill VObject class, move base selector classes to appobject
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2552
diff
changeset
|
82 |
cube_appobject_path = CubicWebConfiguration.cube_appobject_path | set(['views']) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
83 |
|
0 | 84 |
options = merge_options(CubicWebConfiguration.options + ( |
8669
62213a34726e
[db-api/configuration] simplify db-api and configuration so that all the connection information is in the repository url, closes #2521848
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8605
diff
changeset
|
85 |
('repository-uri', |
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
86 |
{'type': 'string', |
8669
62213a34726e
[db-api/configuration] simplify db-api and configuration so that all the connection information is in the repository url, closes #2521848
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8605
diff
changeset
|
87 |
'default': 'inmemory://', |
62213a34726e
[db-api/configuration] simplify db-api and configuration so that all the connection information is in the repository url, closes #2521848
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8605
diff
changeset
|
88 |
'help': 'see `cubicweb.dbapi.connect` documentation for possible value', |
62213a34726e
[db-api/configuration] simplify db-api and configuration so that all the connection information is in the repository url, closes #2521848
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8605
diff
changeset
|
89 |
'group': 'web', 'level': 2, |
62213a34726e
[db-api/configuration] simplify db-api and configuration so that all the connection information is in the repository url, closes #2521848
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8605
diff
changeset
|
90 |
}), |
12010
c34590161082
web: add options to ignore css compilation and uicache
Samuel Trégouët <samuel.tregouet@logilab.fr>
parents:
11929
diff
changeset
|
91 |
('use-uicache', |
c34590161082
web: add options to ignore css compilation and uicache
Samuel Trégouët <samuel.tregouet@logilab.fr>
parents:
11929
diff
changeset
|
92 |
{'type': 'yn', 'default': True, |
c34590161082
web: add options to ignore css compilation and uicache
Samuel Trégouët <samuel.tregouet@logilab.fr>
parents:
11929
diff
changeset
|
93 |
'help': _('should css be compiled and store in uicache'), |
12017
281a6219bdc9
[web] Put 'use-uicache' option in level 2
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12010
diff
changeset
|
94 |
'group': 'ui', 'level': 2, |
12010
c34590161082
web: add options to ignore css compilation and uicache
Samuel Trégouët <samuel.tregouet@logilab.fr>
parents:
11929
diff
changeset
|
95 |
}), |
0 | 96 |
('anonymous-user', |
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
97 |
{'type': 'string', |
0 | 98 |
'default': None, |
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
99 |
'help': ('login of the CubicWeb user account to use for anonymous ' |
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
100 |
'user (if you want to allow anonymous)'), |
5554
9b7bdbfee68b
[config] move web specific config to the web section of the configuration file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5515
diff
changeset
|
101 |
'group': 'web', 'level': 1, |
0 | 102 |
}), |
103 |
('anonymous-password', |
|
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
104 |
{'type': 'string', |
0 | 105 |
'default': None, |
106 |
'help': 'password of the CubicWeb user account to use for anonymous user, ' |
|
107 |
'if anonymous-user is set', |
|
5554
9b7bdbfee68b
[config] move web specific config to the web section of the configuration file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5515
diff
changeset
|
108 |
'group': 'web', 'level': 1, |
0 | 109 |
}), |
110 |
('query-log-file', |
|
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
111 |
{'type': 'string', |
0 | 112 |
'default': None, |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2267
diff
changeset
|
113 |
'help': 'web instance query log file', |
5554
9b7bdbfee68b
[config] move web specific config to the web section of the configuration file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5515
diff
changeset
|
114 |
'group': 'web', 'level': 3, |
0 | 115 |
}), |
12019
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
116 |
('cleanup-anonymous-session-time', |
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
117 |
{'type': 'time', |
12019
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
118 |
'default': '5min', |
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
119 |
'help': 'Same as cleanup-session-time but specific to anonymous ' |
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
120 |
'sessions. You can have a much smaller timeout here since it will be ' |
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
121 |
'transparent to the user. Default to 5min.', |
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
122 |
'group': 'web', 'level': 3, |
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
123 |
}), |
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
124 |
)) |
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
125 |
|
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
126 |
def anonymous_user(self): |
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
127 |
"""return a login and password to use for anonymous users. |
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
128 |
|
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
129 |
None may be returned for both if anonymous connection is not |
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
130 |
allowed or if an empty login is used in configuration |
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
131 |
""" |
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
132 |
try: |
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
133 |
user = self['anonymous-user'] or None |
12019
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
134 |
passwd = self['anonymous-password'] |
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
135 |
except KeyError: |
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
136 |
user, passwd = None, None |
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
137 |
except UnicodeDecodeError: |
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
138 |
raise ConfigurationError("anonymous information should only contains ascii") |
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
139 |
return user, passwd |
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
140 |
|
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
141 |
|
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
142 |
class WebConfiguration(BaseWebConfiguration): |
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
143 |
"""the WebConfiguration is a singleton object handling instance's |
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
144 |
configuration and preferences |
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
145 |
""" |
9759aefa047b
[web] Extract a base class out WebConfiguration
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12017
diff
changeset
|
146 |
options = merge_options(BaseWebConfiguration.options + ( |
0 | 147 |
# web configuration |
10323
8cc58e8ad72f
[web] Add datadir-url configuration option (closes #5204550)
Julien Cristau <julien.cristau@logilab.fr>
parents:
10322
diff
changeset
|
148 |
('datadir-url', |
8cc58e8ad72f
[web] Add datadir-url configuration option (closes #5204550)
Julien Cristau <julien.cristau@logilab.fr>
parents:
10322
diff
changeset
|
149 |
{'type': 'string', 'default': None, |
8cc58e8ad72f
[web] Add datadir-url configuration option (closes #5204550)
Julien Cristau <julien.cristau@logilab.fr>
parents:
10322
diff
changeset
|
150 |
'help': ('base url for static data, if different from "${base-url}/data/". ' |
8cc58e8ad72f
[web] Add datadir-url configuration option (closes #5204550)
Julien Cristau <julien.cristau@logilab.fr>
parents:
10322
diff
changeset
|
151 |
'If served from a different domain, that domain should allow ' |
8cc58e8ad72f
[web] Add datadir-url configuration option (closes #5204550)
Julien Cristau <julien.cristau@logilab.fr>
parents:
10322
diff
changeset
|
152 |
'cross-origin requests.'), |
8cc58e8ad72f
[web] Add datadir-url configuration option (closes #5204550)
Julien Cristau <julien.cristau@logilab.fr>
parents:
10322
diff
changeset
|
153 |
'group': 'web', |
8cc58e8ad72f
[web] Add datadir-url configuration option (closes #5204550)
Julien Cristau <julien.cristau@logilab.fr>
parents:
10322
diff
changeset
|
154 |
}), |
0 | 155 |
('auth-mode', |
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
156 |
{'type': 'choice', |
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
157 |
'choices': ('cookie', 'http'), |
0 | 158 |
'default': 'cookie', |
159 |
'help': 'authentication mode (cookie / http)', |
|
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
160 |
'group': 'web', 'level': 3, |
0 | 161 |
}), |
162 |
('realm', |
|
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
163 |
{'type': 'string', |
0 | 164 |
'default': 'cubicweb', |
165 |
'help': 'realm to use on HTTP authentication mode', |
|
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
166 |
'group': 'web', 'level': 3, |
0 | 167 |
}), |
168 |
('http-session-time', |
|
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
169 |
{'type': 'time', |
0 | 170 |
'default': 0, |
5326
0d9054eb3bd1
[config] properly use time type for options representing a time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5283
diff
changeset
|
171 |
'help': "duration of the cookie used to store session identifier. " |
0d9054eb3bd1
[config] properly use time type for options representing a time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5283
diff
changeset
|
172 |
"If 0, the cookie will expire when the user exist its browser. " |
0d9054eb3bd1
[config] properly use time type for options representing a time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5283
diff
changeset
|
173 |
"Should be 0 or greater than repository\'s session-time.", |
5515
513af9be9e37
[config] rename remaining inputlevel to level in option definitions, as expected by lgc >= 0.50
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5500
diff
changeset
|
174 |
'group': 'web', 'level': 2, |
0 | 175 |
}), |
176 |
('submit-mail', |
|
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
177 |
{'type': 'string', |
0 | 178 |
'default': None, |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2267
diff
changeset
|
179 |
'help': ('Mail used as recipient to report bug in this instance, ' |
0 | 180 |
'if you want this feature on'), |
5323
329b4f6d18b4
[config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5283
diff
changeset
|
181 |
'group': 'web', 'level': 2, |
0 | 182 |
}), |
183 |
||
11794
d8830e2bd2e0
[req,web] Make it possible to handle page language from URL prefix
Laura Médioni <laura.medioni@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11767
diff
changeset
|
184 |
('language-mode', |
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
185 |
{'type': 'choice', |
11794
d8830e2bd2e0
[req,web] Make it possible to handle page language from URL prefix
Laura Médioni <laura.medioni@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11767
diff
changeset
|
186 |
'choices': ('http-negotiation', 'url-prefix', ''), |
d8830e2bd2e0
[req,web] Make it possible to handle page language from URL prefix
Laura Médioni <laura.medioni@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11767
diff
changeset
|
187 |
'default': 'http-negotiation', |
d8830e2bd2e0
[req,web] Make it possible to handle page language from URL prefix
Laura Médioni <laura.medioni@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11767
diff
changeset
|
188 |
'help': ('source for interface\'s language detection. ' |
d8830e2bd2e0
[req,web] Make it possible to handle page language from URL prefix
Laura Médioni <laura.medioni@logilab.fr>, Denis Laxalde <denis.laxalde@logilab.fr>
parents:
11767
diff
changeset
|
189 |
'If set to "http-negotiation" the Accept-Language HTTP header will be used,' |
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
190 |
' if set to "url-prefix", the URL will be inspected for a' |
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
191 |
' short language prefix.'), |
5323
329b4f6d18b4
[config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5283
diff
changeset
|
192 |
'group': 'web', 'level': 2, |
0 | 193 |
}), |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
194 |
|
0 | 195 |
('print-traceback', |
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
196 |
{'type': 'yn', |
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:
3539
diff
changeset
|
197 |
'default': CubicWebConfiguration.mode != 'system', |
6109
47d9c0e0f7b7
integrate Celso's work on translation file: proper/complete spanish translation, fixed some typos in french translation, occured -> occurred fix in various places
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6061
diff
changeset
|
198 |
'help': 'print the traceback on the error page when an error occurred', |
5323
329b4f6d18b4
[config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5283
diff
changeset
|
199 |
'group': 'web', 'level': 2, |
0 | 200 |
}), |
4595
bb08a75832e6
backport crypto/captcha utilities from the registration cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
201 |
|
bb08a75832e6
backport crypto/captcha utilities from the registration cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
202 |
('captcha-font-file', |
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
203 |
{'type': 'string', |
12268
d84bc85f7f70
[config] Avoid relying on shared_dir method when possible
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12019
diff
changeset
|
204 |
'default': join(_DATA_DIR, 'porkys.ttf'), |
4595
bb08a75832e6
backport crypto/captcha utilities from the registration cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
205 |
'help': 'True type font to use for captcha image generation (you \ |
bb08a75832e6
backport crypto/captcha utilities from the registration cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
206 |
must have the python imaging library installed to use captcha)', |
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
207 |
'group': 'web', 'level': 3, |
4595
bb08a75832e6
backport crypto/captcha utilities from the registration cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
208 |
}), |
bb08a75832e6
backport crypto/captcha utilities from the registration cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
209 |
('captcha-font-size', |
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
210 |
{'type': 'int', |
4595
bb08a75832e6
backport crypto/captcha utilities from the registration cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
211 |
'default': 25, |
bb08a75832e6
backport crypto/captcha utilities from the registration cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
212 |
'help': 'Font size to use for captcha image generation (you must \ |
bb08a75832e6
backport crypto/captcha utilities from the registration cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
213 |
have the python imaging library installed to use captcha)', |
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
214 |
'group': 'web', 'level': 3, |
4595
bb08a75832e6
backport crypto/captcha utilities from the registration cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
215 |
}), |
bb08a75832e6
backport crypto/captcha utilities from the registration cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
216 |
|
7762
a3f9ba4d44eb
[web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7380
diff
changeset
|
217 |
('concat-resources', |
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
218 |
{'type': 'yn', |
9595
240a620b9cd3
[web] Disable 'concat-resources' by default (closes #3670503)
Rémi Cardona <remi.cardona@logilab.fr>
parents:
9372
diff
changeset
|
219 |
'default': False, |
7762
a3f9ba4d44eb
[web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7380
diff
changeset
|
220 |
'help': 'use modconcat-like URLS to concat and serve JS / CSS files', |
a3f9ba4d44eb
[web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7380
diff
changeset
|
221 |
'group': 'web', 'level': 2, |
a3f9ba4d44eb
[web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7380
diff
changeset
|
222 |
}), |
8601
1a6000ff2080
[web] add a ``anonymize-jsonp-queries`` option in file configuration (closes #2465388)
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
8475
diff
changeset
|
223 |
('anonymize-jsonp-queries', |
1a6000ff2080
[web] add a ``anonymize-jsonp-queries`` option in file configuration (closes #2465388)
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
8475
diff
changeset
|
224 |
{'type': 'yn', |
1a6000ff2080
[web] add a ``anonymize-jsonp-queries`` option in file configuration (closes #2465388)
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
8475
diff
changeset
|
225 |
'default': True, |
1a6000ff2080
[web] add a ``anonymize-jsonp-queries`` option in file configuration (closes #2465388)
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
8475
diff
changeset
|
226 |
'help': 'anonymize the connection before executing any jsonp query.', |
1a6000ff2080
[web] add a ``anonymize-jsonp-queries`` option in file configuration (closes #2465388)
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
8475
diff
changeset
|
227 |
'group': 'web', 'level': 1 |
1a6000ff2080
[web] add a ``anonymize-jsonp-queries`` option in file configuration (closes #2465388)
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
8475
diff
changeset
|
228 |
}), |
9372
e87a808a4c32
[webctl] Generate static data directory on upgrade (closes #2167873)
Julien Cristau <julien.cristau@logilab.fr>
parents:
9340
diff
changeset
|
229 |
('generate-staticdir', |
e87a808a4c32
[webctl] Generate static data directory on upgrade (closes #2167873)
Julien Cristau <julien.cristau@logilab.fr>
parents:
9340
diff
changeset
|
230 |
{'type': 'yn', |
11229
0276f1246a4d
[webconfig] disable generate-staticdir by default
Julien Cristau <julien.cristau@logilab.fr>
parents:
11057
diff
changeset
|
231 |
'default': False, |
9372
e87a808a4c32
[webctl] Generate static data directory on upgrade (closes #2167873)
Julien Cristau <julien.cristau@logilab.fr>
parents:
9340
diff
changeset
|
232 |
'help': 'Generate the static data resource directory on upgrade.', |
e87a808a4c32
[webctl] Generate static data directory on upgrade (closes #2167873)
Julien Cristau <julien.cristau@logilab.fr>
parents:
9340
diff
changeset
|
233 |
'group': 'web', 'level': 2, |
e87a808a4c32
[webctl] Generate static data directory on upgrade (closes #2167873)
Julien Cristau <julien.cristau@logilab.fr>
parents:
9340
diff
changeset
|
234 |
}), |
e87a808a4c32
[webctl] Generate static data directory on upgrade (closes #2167873)
Julien Cristau <julien.cristau@logilab.fr>
parents:
9340
diff
changeset
|
235 |
('staticdir-path', |
e87a808a4c32
[webctl] Generate static data directory on upgrade (closes #2167873)
Julien Cristau <julien.cristau@logilab.fr>
parents:
9340
diff
changeset
|
236 |
{'type': 'string', |
e87a808a4c32
[webctl] Generate static data directory on upgrade (closes #2167873)
Julien Cristau <julien.cristau@logilab.fr>
parents:
9340
diff
changeset
|
237 |
'default': None, |
e87a808a4c32
[webctl] Generate static data directory on upgrade (closes #2167873)
Julien Cristau <julien.cristau@logilab.fr>
parents:
9340
diff
changeset
|
238 |
'help': 'The static data resource directory path.', |
e87a808a4c32
[webctl] Generate static data directory on upgrade (closes #2167873)
Julien Cristau <julien.cristau@logilab.fr>
parents:
9340
diff
changeset
|
239 |
'group': 'web', 'level': 2, |
e87a808a4c32
[webctl] Generate static data directory on upgrade (closes #2167873)
Julien Cristau <julien.cristau@logilab.fr>
parents:
9340
diff
changeset
|
240 |
}), |
9571
aaf83cc07eed
[web] implement cross origin resource sharing (CORS) (closes #2491768)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
9504
diff
changeset
|
241 |
('access-control-allow-origin', |
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
242 |
{'type': 'csv', |
9571
aaf83cc07eed
[web] implement cross origin resource sharing (CORS) (closes #2491768)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
9504
diff
changeset
|
243 |
'default': (), |
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
244 |
'help': ('comma-separated list of allowed origin domains or "*" for any domain'), |
9571
aaf83cc07eed
[web] implement cross origin resource sharing (CORS) (closes #2491768)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
9504
diff
changeset
|
245 |
'group': 'web', 'level': 2, |
aaf83cc07eed
[web] implement cross origin resource sharing (CORS) (closes #2491768)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
9504
diff
changeset
|
246 |
}), |
aaf83cc07eed
[web] implement cross origin resource sharing (CORS) (closes #2491768)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
9504
diff
changeset
|
247 |
('access-control-allow-methods', |
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
248 |
{'type': 'csv', |
9571
aaf83cc07eed
[web] implement cross origin resource sharing (CORS) (closes #2491768)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
9504
diff
changeset
|
249 |
'default': (), |
aaf83cc07eed
[web] implement cross origin resource sharing (CORS) (closes #2491768)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
9504
diff
changeset
|
250 |
'help': ('comma-separated list of allowed HTTP methods'), |
aaf83cc07eed
[web] implement cross origin resource sharing (CORS) (closes #2491768)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
9504
diff
changeset
|
251 |
'group': 'web', 'level': 2, |
aaf83cc07eed
[web] implement cross origin resource sharing (CORS) (closes #2491768)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
9504
diff
changeset
|
252 |
}), |
aaf83cc07eed
[web] implement cross origin resource sharing (CORS) (closes #2491768)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
9504
diff
changeset
|
253 |
('access-control-max-age', |
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
254 |
{'type': 'int', |
9571
aaf83cc07eed
[web] implement cross origin resource sharing (CORS) (closes #2491768)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
9504
diff
changeset
|
255 |
'default': None, |
aaf83cc07eed
[web] implement cross origin resource sharing (CORS) (closes #2491768)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
9504
diff
changeset
|
256 |
'help': ('maximum age of cross-origin resource sharing (in seconds)'), |
aaf83cc07eed
[web] implement cross origin resource sharing (CORS) (closes #2491768)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
9504
diff
changeset
|
257 |
'group': 'web', 'level': 2, |
aaf83cc07eed
[web] implement cross origin resource sharing (CORS) (closes #2491768)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
9504
diff
changeset
|
258 |
}), |
aaf83cc07eed
[web] implement cross origin resource sharing (CORS) (closes #2491768)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
9504
diff
changeset
|
259 |
('access-control-expose-headers', |
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
260 |
{'type': 'csv', |
9571
aaf83cc07eed
[web] implement cross origin resource sharing (CORS) (closes #2491768)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
9504
diff
changeset
|
261 |
'default': (), |
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
262 |
'help': ('comma-separated list of HTTP headers the application ' |
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
263 |
'declare in response to a preflight request'), |
9571
aaf83cc07eed
[web] implement cross origin resource sharing (CORS) (closes #2491768)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
9504
diff
changeset
|
264 |
'group': 'web', 'level': 2, |
aaf83cc07eed
[web] implement cross origin resource sharing (CORS) (closes #2491768)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
9504
diff
changeset
|
265 |
}), |
aaf83cc07eed
[web] implement cross origin resource sharing (CORS) (closes #2491768)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
9504
diff
changeset
|
266 |
('access-control-allow-headers', |
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
267 |
{'type': 'csv', |
9571
aaf83cc07eed
[web] implement cross origin resource sharing (CORS) (closes #2491768)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
9504
diff
changeset
|
268 |
'default': (), |
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
269 |
'help': ('comma-separated list of HTTP headers the application may set in the response'), |
9571
aaf83cc07eed
[web] implement cross origin resource sharing (CORS) (closes #2491768)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
9504
diff
changeset
|
270 |
'group': 'web', 'level': 2, |
aaf83cc07eed
[web] implement cross origin resource sharing (CORS) (closes #2491768)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
9504
diff
changeset
|
271 |
}), |
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
272 |
)) |
0 | 273 |
|
8868
12f29b0ed0bb
[webconfig] explicit some webconfig attribute
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8669
diff
changeset
|
274 |
def __init__(self, *args, **kwargs): |
12f29b0ed0bb
[webconfig] explicit some webconfig attribute
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8669
diff
changeset
|
275 |
super(WebConfiguration, self).__init__(*args, **kwargs) |
12f29b0ed0bb
[webconfig] explicit some webconfig attribute
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8669
diff
changeset
|
276 |
self.uiprops = None |
12f29b0ed0bb
[webconfig] explicit some webconfig attribute
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8669
diff
changeset
|
277 |
self.datadir_url = None |
12f29b0ed0bb
[webconfig] explicit some webconfig attribute
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8669
diff
changeset
|
278 |
|
890
3530baff9120
make fckeditor actually optional, fix its config, avoid needs for a link to fckeditor.js
sylvain.thenault@logilab.fr
parents:
823
diff
changeset
|
279 |
def fckeditor_installed(self): |
8870
c9d18b8dbfea
[webconfig] cleanly handles ``fckeditor_installed`` when no uiprops
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8868
diff
changeset
|
280 |
if self.uiprops is None: |
c9d18b8dbfea
[webconfig] cleanly handles ``fckeditor_installed`` when no uiprops
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8868
diff
changeset
|
281 |
return False |
c9d18b8dbfea
[webconfig] cleanly handles ``fckeditor_installed`` when no uiprops
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8868
diff
changeset
|
282 |
return exists(self.uiprops.get('FCKEDITOR_PATH', '')) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
283 |
|
7031
a04621040cad
[config refactoring] rename eproperty_definition method to cwproperty_definition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6425
diff
changeset
|
284 |
def cwproperty_definitions(self): |
a04621040cad
[config refactoring] rename eproperty_definition method to cwproperty_definition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6425
diff
changeset
|
285 |
for key, pdef in super(WebConfiguration, self).cwproperty_definitions(): |
890
3530baff9120
make fckeditor actually optional, fix its config, avoid needs for a link to fckeditor.js
sylvain.thenault@logilab.fr
parents:
823
diff
changeset
|
286 |
if key == 'ui.fckeditor' and not self.fckeditor_installed(): |
3530baff9120
make fckeditor actually optional, fix its config, avoid needs for a link to fckeditor.js
sylvain.thenault@logilab.fr
parents:
823
diff
changeset
|
287 |
continue |
3530baff9120
make fckeditor actually optional, fix its config, avoid needs for a link to fckeditor.js
sylvain.thenault@logilab.fr
parents:
823
diff
changeset
|
288 |
yield key, pdef |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
289 |
|
8605
797fc2e2fb78
[web] add a digital signature to error form (closes #2522526)
David Douard <david.douard@logilab.fr>
parents:
8601
diff
changeset
|
290 |
@cachedproperty |
797fc2e2fb78
[web] add a digital signature to error form (closes #2522526)
David Douard <david.douard@logilab.fr>
parents:
8601
diff
changeset
|
291 |
def _instance_salt(self): |
797fc2e2fb78
[web] add a digital signature to error form (closes #2522526)
David Douard <david.douard@logilab.fr>
parents:
8601
diff
changeset
|
292 |
"""This random key/salt is used to sign content to be sent back by |
797fc2e2fb78
[web] add a digital signature to error form (closes #2522526)
David Douard <david.douard@logilab.fr>
parents:
8601
diff
changeset
|
293 |
browsers, eg. in the error report form. |
797fc2e2fb78
[web] add a digital signature to error form (closes #2522526)
David Douard <david.douard@logilab.fr>
parents:
8601
diff
changeset
|
294 |
""" |
10692
14e7ddb0f670
[py3k] unicode → six.text_type
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10666
diff
changeset
|
295 |
return str(uuid4()).encode('ascii') |
8605
797fc2e2fb78
[web] add a digital signature to error form (closes #2522526)
David Douard <david.douard@logilab.fr>
parents:
8601
diff
changeset
|
296 |
|
797fc2e2fb78
[web] add a digital signature to error form (closes #2522526)
David Douard <david.douard@logilab.fr>
parents:
8601
diff
changeset
|
297 |
def sign_text(self, text): |
797fc2e2fb78
[web] add a digital signature to error form (closes #2522526)
David Douard <david.douard@logilab.fr>
parents:
8601
diff
changeset
|
298 |
"""sign some text for later checking""" |
9326
9d145b4c4e53
[web] make sign_text unicode aware, avoid crash with non-ascii chars. Closes #3289774
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9317
diff
changeset
|
299 |
# hmac.new expect bytes |
12567
26744ad37953
Drop python2 support
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12542
diff
changeset
|
300 |
if isinstance(text, str): |
9326
9d145b4c4e53
[web] make sign_text unicode aware, avoid crash with non-ascii chars. Closes #3289774
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9317
diff
changeset
|
301 |
text = text.encode('utf-8') |
8605
797fc2e2fb78
[web] add a digital signature to error form (closes #2522526)
David Douard <david.douard@logilab.fr>
parents:
8601
diff
changeset
|
302 |
# replace \r\n so we do not depend on whether a browser "reencode" |
797fc2e2fb78
[web] add a digital signature to error form (closes #2522526)
David Douard <david.douard@logilab.fr>
parents:
8601
diff
changeset
|
303 |
# original message using \r\n or not |
797fc2e2fb78
[web] add a digital signature to error form (closes #2522526)
David Douard <david.douard@logilab.fr>
parents:
8601
diff
changeset
|
304 |
return hmac.new(self._instance_salt, |
12584
6eba53763482
Use secure hash algorithm in WebConfiguration.sign_text
Laurent Peuch <cortex@worlddomination.be>
parents:
12567
diff
changeset
|
305 |
text.strip().replace(b'\r\n', b'\n'), |
6eba53763482
Use secure hash algorithm in WebConfiguration.sign_text
Laurent Peuch <cortex@worlddomination.be>
parents:
12567
diff
changeset
|
306 |
digestmod="sha3_512").hexdigest() |
8605
797fc2e2fb78
[web] add a digital signature to error form (closes #2522526)
David Douard <david.douard@logilab.fr>
parents:
8601
diff
changeset
|
307 |
|
797fc2e2fb78
[web] add a digital signature to error form (closes #2522526)
David Douard <david.douard@logilab.fr>
parents:
8601
diff
changeset
|
308 |
def check_text_sign(self, text, signature): |
797fc2e2fb78
[web] add a digital signature to error form (closes #2522526)
David Douard <david.douard@logilab.fr>
parents:
8601
diff
changeset
|
309 |
"""check the text signature is equal to the given signature""" |
797fc2e2fb78
[web] add a digital signature to error form (closes #2522526)
David Douard <david.douard@logilab.fr>
parents:
8601
diff
changeset
|
310 |
return self.sign_text(text) == signature |
797fc2e2fb78
[web] add a digital signature to error form (closes #2522526)
David Douard <david.douard@logilab.fr>
parents:
8601
diff
changeset
|
311 |
|
0 | 312 |
def locate_resource(self, rid): |
5907
5eba1248e12b
[web config] fix old css compat code: we have to modify locate_resource prototype so it return (potentially hacked) file name as well. Should only impact the file cube which has to be released anyway.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5902
diff
changeset
|
313 |
"""return the (directory, filename) where the given resource |
5eba1248e12b
[web config] fix old css compat code: we have to modify locate_resource prototype so it return (potentially hacked) file name as well. Should only impact the file cube which has to be released anyway.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5902
diff
changeset
|
314 |
may be found |
5eba1248e12b
[web config] fix old css compat code: we have to modify locate_resource prototype so it return (potentially hacked) file name as well. Should only impact the file cube which has to be released anyway.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5902
diff
changeset
|
315 |
""" |
0 | 316 |
return self._fs_locate(rid, 'data') |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
317 |
|
0 | 318 |
def locate_doc_file(self, fname): |
319 |
"""return the directory where the given resource may be found""" |
|
5907
5eba1248e12b
[web config] fix old css compat code: we have to modify locate_resource prototype so it return (potentially hacked) file name as well. Should only impact the file cube which has to be released anyway.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5902
diff
changeset
|
320 |
return self._fs_locate(fname, 'wdoc')[0] |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
321 |
|
5466
b5af2ac0c43c
[uiprops] test and fix reloading of modified css files; update c-c newcube; deprecates config.has_resource.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5445
diff
changeset
|
322 |
@cached |
b5af2ac0c43c
[uiprops] test and fix reloading of modified css files; update c-c newcube; deprecates config.has_resource.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5445
diff
changeset
|
323 |
def _fs_path_locate(self, rid, rdirectory): |
0 | 324 |
"""return the directory where the given resource may be found""" |
12268
d84bc85f7f70
[config] Avoid relying on shared_dir method when possible
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12019
diff
changeset
|
325 |
path = [self.apphome] + self.cubes_path() + [dirname(__file__)] |
0 | 326 |
for directory in path: |
327 |
if exists(join(directory, rdirectory, rid)): |
|
5466
b5af2ac0c43c
[uiprops] test and fix reloading of modified css files; update c-c newcube; deprecates config.has_resource.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5445
diff
changeset
|
328 |
return directory |
b5af2ac0c43c
[uiprops] test and fix reloading of modified css files; update c-c newcube; deprecates config.has_resource.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5445
diff
changeset
|
329 |
|
b5af2ac0c43c
[uiprops] test and fix reloading of modified css files; update c-c newcube; deprecates config.has_resource.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5445
diff
changeset
|
330 |
def _fs_locate(self, rid, rdirectory): |
5907
5eba1248e12b
[web config] fix old css compat code: we have to modify locate_resource prototype so it return (potentially hacked) file name as well. Should only impact the file cube which has to be released anyway.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5902
diff
changeset
|
331 |
"""return the (directory, filename) where the given resource |
5eba1248e12b
[web config] fix old css compat code: we have to modify locate_resource prototype so it return (potentially hacked) file name as well. Should only impact the file cube which has to be released anyway.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5902
diff
changeset
|
332 |
may be found |
5eba1248e12b
[web config] fix old css compat code: we have to modify locate_resource prototype so it return (potentially hacked) file name as well. Should only impact the file cube which has to be released anyway.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5902
diff
changeset
|
333 |
""" |
5466
b5af2ac0c43c
[uiprops] test and fix reloading of modified css files; update c-c newcube; deprecates config.has_resource.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5445
diff
changeset
|
334 |
directory = self._fs_path_locate(rid, rdirectory) |
b5af2ac0c43c
[uiprops] test and fix reloading of modified css files; update c-c newcube; deprecates config.has_resource.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5445
diff
changeset
|
335 |
if directory is None: |
5907
5eba1248e12b
[web config] fix old css compat code: we have to modify locate_resource prototype so it return (potentially hacked) file name as well. Should only impact the file cube which has to be released anyway.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5902
diff
changeset
|
336 |
return None, None |
12010
c34590161082
web: add options to ignore css compilation and uicache
Samuel Trégouët <samuel.tregouet@logilab.fr>
parents:
11929
diff
changeset
|
337 |
if self['use-uicache'] and rdirectory == 'data' and rid.endswith('.css'): |
11437
dbe73990172b
[webconfig] ensure uicache content has correct uid (related to #11298794)
David Douard <david.douard@logilab.fr>
parents:
10922
diff
changeset
|
338 |
return self.ensure_uid_directory( |
12528
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
339 |
self.uiprops.process_resource( |
f9b46b63393e
Flake8 cubicweb/web/webconfig.py
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12503
diff
changeset
|
340 |
join(directory, rdirectory), rid)), rid |
5907
5eba1248e12b
[web config] fix old css compat code: we have to modify locate_resource prototype so it return (potentially hacked) file name as well. Should only impact the file cube which has to be released anyway.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5902
diff
changeset
|
341 |
return join(directory, rdirectory), rid |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
342 |
|
0 | 343 |
def locate_all_files(self, rid, rdirectory='wdoc'): |
344 |
"""return all files corresponding to the given resource""" |
|
12268
d84bc85f7f70
[config] Avoid relying on shared_dir method when possible
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12019
diff
changeset
|
345 |
path = [self.apphome] + self.cubes_path() + [dirname(__file__)] |
0 | 346 |
for directory in path: |
347 |
fpath = join(directory, rdirectory, rid) |
|
348 |
if exists(fpath): |
|
349 |
yield join(fpath) |
|
350 |
||
10474
1dcc52f5e340
[cwctl] allow overriding config settings from the command line (closes #5557656)
David Douard <david.douard@logilab.fr>
parents:
10323
diff
changeset
|
351 |
def load_configuration(self, **kw): |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2267
diff
changeset
|
352 |
"""load instance's configuration files""" |
10474
1dcc52f5e340
[cwctl] allow overriding config settings from the command line (closes #5557656)
David Douard <david.douard@logilab.fr>
parents:
10323
diff
changeset
|
353 |
super(WebConfiguration, self).load_configuration(**kw) |
0 | 354 |
# load external resources definition |
355 |
self._init_base_url() |
|
5444
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5443
diff
changeset
|
356 |
self._build_ui_properties() |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
357 |
|
0 | 358 |
def _init_base_url(self): |
359 |
# normalize base url(s) |
|
4909
a13c1d1ecc5b
[web server] simplify base-url handling on startup. Ensure config['base-url'] is correctly set once started
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
360 |
baseurl = self['base-url'] or self.default_base_url() |
0 | 361 |
if baseurl and baseurl[-1] != '/': |
362 |
baseurl += '/' |
|
7130
5eb622c0c672
[config] do not set base-url during instance creation, we don't want generated value to ends up in the configuration file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7031
diff
changeset
|
363 |
if not (self.repairing or self.creating): |
5005
b04ec1b6f7da
don't rewrite config's url during migration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4909
diff
changeset
|
364 |
self.global_set_option('base-url', baseurl) |
10323
8cc58e8ad72f
[web] Add datadir-url configuration option (closes #5204550)
Julien Cristau <julien.cristau@logilab.fr>
parents:
10322
diff
changeset
|
365 |
self.datadir_url = self['datadir-url'] |
8cc58e8ad72f
[web] Add datadir-url configuration option (closes #5204550)
Julien Cristau <julien.cristau@logilab.fr>
parents:
10322
diff
changeset
|
366 |
if self.datadir_url: |
8cc58e8ad72f
[web] Add datadir-url configuration option (closes #5204550)
Julien Cristau <julien.cristau@logilab.fr>
parents:
10322
diff
changeset
|
367 |
if self.datadir_url[-1] != '/': |
8cc58e8ad72f
[web] Add datadir-url configuration option (closes #5204550)
Julien Cristau <julien.cristau@logilab.fr>
parents:
10322
diff
changeset
|
368 |
self.datadir_url += '/' |
8cc58e8ad72f
[web] Add datadir-url configuration option (closes #5204550)
Julien Cristau <julien.cristau@logilab.fr>
parents:
10322
diff
changeset
|
369 |
if self.mode != 'test': |
8cc58e8ad72f
[web] Add datadir-url configuration option (closes #5204550)
Julien Cristau <julien.cristau@logilab.fr>
parents:
10322
diff
changeset
|
370 |
self.datadir_url += '%s/' % self.instance_md5_version() |
8cc58e8ad72f
[web] Add datadir-url configuration option (closes #5204550)
Julien Cristau <julien.cristau@logilab.fr>
parents:
10322
diff
changeset
|
371 |
return |
8259
1c5be4a1afd1
[web/config] refactor initialization of the data url
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8186
diff
changeset
|
372 |
data_relpath = self.data_relpath() |
1c5be4a1afd1
[web/config] refactor initialization of the data url
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8186
diff
changeset
|
373 |
self.datadir_url = baseurl + data_relpath |
1c5be4a1afd1
[web/config] refactor initialization of the data url
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8186
diff
changeset
|
374 |
|
1c5be4a1afd1
[web/config] refactor initialization of the data url
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8186
diff
changeset
|
375 |
def data_relpath(self): |
8475
65fecbeb9c3a
[webconfig] debug mode should not be special wrt data_url handling (closes #2405487)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8349
diff
changeset
|
376 |
if self.mode == 'test': |
8259
1c5be4a1afd1
[web/config] refactor initialization of the data url
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8186
diff
changeset
|
377 |
return 'data/' |
8475
65fecbeb9c3a
[webconfig] debug mode should not be special wrt data_url handling (closes #2405487)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8349
diff
changeset
|
378 |
return 'data/%s/' % self.instance_md5_version() |
0 | 379 |
|
5444
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5443
diff
changeset
|
380 |
def _build_ui_properties(self): |
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5443
diff
changeset
|
381 |
# self.datadir_url[:-1] to remove trailing / |
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5443
diff
changeset
|
382 |
from cubicweb.web.propertysheet import PropertySheet |
5933
3d707b8f8a4d
[web configuration] ensure data home directory / uicache file belong to daemon user and are writeable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5907
diff
changeset
|
383 |
cachedir = join(self.appdatahome, 'uicache') |
3d707b8f8a4d
[web configuration] ensure data home directory / uicache file belong to daemon user and are writeable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5907
diff
changeset
|
384 |
self.check_writeable_uid_directory(cachedir) |
5445
4467ed43d97d
[web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5444
diff
changeset
|
385 |
self.uiprops = PropertySheet( |
5933
3d707b8f8a4d
[web configuration] ensure data home directory / uicache file belong to daemon user and are writeable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5907
diff
changeset
|
386 |
cachedir, |
5445
4467ed43d97d
[web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5444
diff
changeset
|
387 |
data=lambda x: self.datadir_url + x, |
4467ed43d97d
[web] use uiprops value to compile css transparently, handlig cache and reloading in debug mode
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5444
diff
changeset
|
388 |
datadir_url=self.datadir_url[:-1]) |
5467
57372dbfd114
[https] fix resource urls in https version of a site: should use the https version as well to avoid warnings from the nrowser
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5466
diff
changeset
|
389 |
self._init_uiprops(self.uiprops) |
57372dbfd114
[https] fix resource urls in https version of a site: should use the https version as well to avoid warnings from the nrowser
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5466
diff
changeset
|
390 |
|
57372dbfd114
[https] fix resource urls in https version of a site: should use the https version as well to avoid warnings from the nrowser
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5466
diff
changeset
|
391 |
def _init_uiprops(self, uiprops): |
12268
d84bc85f7f70
[config] Avoid relying on shared_dir method when possible
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12019
diff
changeset
|
392 |
libuiprops = join(_DATA_DIR, 'uiprops.py') |
5467
57372dbfd114
[https] fix resource urls in https version of a site: should use the https version as well to avoid warnings from the nrowser
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5466
diff
changeset
|
393 |
uiprops.load(libuiprops) |
0 | 394 |
for path in reversed([self.apphome] + self.cubes_path()): |
5467
57372dbfd114
[https] fix resource urls in https version of a site: should use the https version as well to avoid warnings from the nrowser
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5466
diff
changeset
|
395 |
self._load_ui_properties_file(uiprops, path) |
57372dbfd114
[https] fix resource urls in https version of a site: should use the https version as well to avoid warnings from the nrowser
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5466
diff
changeset
|
396 |
self._load_ui_properties_file(uiprops, self.apphome) |
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5555
diff
changeset
|
397 |
datadir_url = uiprops.context['datadir_url'] |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5555
diff
changeset
|
398 |
cubicweb_js_url = datadir_url + '/cubicweb.js' |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5555
diff
changeset
|
399 |
if cubicweb_js_url not in uiprops['JAVASCRIPTS']: |
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5555
diff
changeset
|
400 |
uiprops['JAVASCRIPTS'].insert(0, cubicweb_js_url) |
5444
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5443
diff
changeset
|
401 |
|
5467
57372dbfd114
[https] fix resource urls in https version of a site: should use the https version as well to avoid warnings from the nrowser
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5466
diff
changeset
|
402 |
def _load_ui_properties_file(self, uiprops, path): |
5444
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5443
diff
changeset
|
403 |
uipropsfile = join(path, 'uiprops.py') |
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5443
diff
changeset
|
404 |
if exists(uipropsfile): |
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5443
diff
changeset
|
405 |
self.debug('loading %s', uipropsfile) |
5467
57372dbfd114
[https] fix resource urls in https version of a site: should use the https version as well to avoid warnings from the nrowser
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5466
diff
changeset
|
406 |
uiprops.load(uipropsfile) |
151
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
407 |
|
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
408 |
# static files handling ################################################### |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
409 |
|
151
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
410 |
@property |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
411 |
def static_directory(self): |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
412 |
return join(self.appdatahome, 'static') |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
413 |
|
151
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
414 |
def static_file_exists(self, rpath): |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
415 |
return exists(join(self.static_directory, rpath)) |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
416 |
|
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
417 |
def static_file_open(self, rpath, mode='wb'): |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
418 |
staticdir = self.static_directory |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
419 |
rdir, filename = split(rpath) |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
420 |
if rdir: |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
421 |
staticdir = join(staticdir, rdir) |
8341
af813e7d5daa
[etwist] fix static directory serving; closes #2174797
Florent Cayré <florent.cayre@gmail.com>
parents:
8186
diff
changeset
|
422 |
if not isdir(staticdir) and 'w' in mode: |
11437
dbe73990172b
[webconfig] ensure uicache content has correct uid (related to #11298794)
David Douard <david.douard@logilab.fr>
parents:
10922
diff
changeset
|
423 |
self.check_writeable_uid_directory(staticdir) |
10614
57dfde80df11
[py3k] file → open
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10568
diff
changeset
|
424 |
return open(join(staticdir, filename), mode) |
151
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
425 |
|
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
426 |
def static_file_add(self, rpath, data): |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
427 |
stream = self.static_file_open(rpath) |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
428 |
stream.write(data) |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
429 |
stream.close() |
11437
dbe73990172b
[webconfig] ensure uicache content has correct uid (related to #11298794)
David Douard <david.douard@logilab.fr>
parents:
10922
diff
changeset
|
430 |
self.ensure_uid(rpath) |
151
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
431 |
|
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
432 |
def static_file_del(self, rpath): |
447 | 433 |
if self.static_file_exists(rpath): |
151
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
434 |
os.remove(join(self.static_directory, rpath)) |
12529
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
435 |
|
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
436 |
|
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
437 |
class WebConfigurationBase(WebConfiguration): |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
438 |
"""web instance (in a web server) client of a RQL server""" |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
439 |
|
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
440 |
options = merge_options(( |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
441 |
# ctl configuration |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
442 |
('port', |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
443 |
{'type': 'int', |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
444 |
'default': None, |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
445 |
'help': 'http server port number (default to 8080)', |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
446 |
'group': 'web', 'level': 0, |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
447 |
}), |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
448 |
('interface', |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
449 |
{'type': 'string', |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
450 |
'default': '0.0.0.0', |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
451 |
'help': 'http server address on which to listen (default to everywhere)', |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
452 |
'group': 'web', 'level': 1, |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
453 |
}), |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
454 |
('max-post-length', # XXX specific to "wsgi" server |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
455 |
{'type': 'bytes', |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
456 |
'default': '100MB', |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
457 |
'help': 'maximum length of HTTP request. Default to 100 MB.', |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
458 |
'group': 'web', 'level': 1, |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
459 |
}), |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
460 |
('pid-file', |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
461 |
{'type': 'string', |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
462 |
'default': Method('default_pid_file'), |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
463 |
'help': 'repository\'s pid file', |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
464 |
'group': 'main', 'level': 2, |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
465 |
}), |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
466 |
) + WebConfiguration.options) |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
467 |
|
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
468 |
def default_base_url(self): |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
469 |
from socket import getfqdn |
7276f1c89ddd
Separate twisted-specific configuration from WebConfigurationBase class
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
12528
diff
changeset
|
470 |
return 'http://%s:%s/' % (self['host'] or getfqdn().lower(), self['port'] or 8080) |