author | Julien Cristau <julien.cristau@logilab.fr> |
Thu, 30 Jan 2014 15:52:22 +0100 | |
changeset 9504 | 71a11bca251d |
parent 9372 | e87a808a4c32 |
child 9571 | aaf83cc07eed |
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 |
|
20 |
__docformat__ = "restructuredtext en" |
|
2087 | 21 |
_ = unicode |
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 |
8341
af813e7d5daa
[etwist] fix static directory serving; closes #2174797
Florent Cayré <florent.cayre@gmail.com>
parents:
8186
diff
changeset
|
26 |
from os.path import join, exists, split, isdir |
5444
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5443
diff
changeset
|
27 |
from warnings import warn |
0 | 28 |
|
8605
797fc2e2fb78
[web] add a digital signature to error form (closes #2522526)
David Douard <david.douard@logilab.fr>
parents:
8601
diff
changeset
|
29 |
from logilab.common.decorators import cached, cachedproperty |
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
|
30 |
from logilab.common.deprecation import deprecated |
8989
8742f4bf029f
import merge_options directly from logilab.common
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
8941
diff
changeset
|
31 |
from logilab.common.configuration import merge_options |
0 | 32 |
|
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
|
33 |
from cubicweb import ConfigurationError |
0 | 34 |
from cubicweb.toolsutils import read_config |
8989
8742f4bf029f
import merge_options directly from logilab.common
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
8941
diff
changeset
|
35 |
from cubicweb.cwconfig import CubicWebConfiguration, register_persistent_options |
0 | 36 |
|
37 |
||
38 |
register_persistent_options( ( |
|
39 |
# site-wide only web ui configuration |
|
40 |
('site-title', |
|
41 |
{'type' : 'string', 'default': 'unset title', |
|
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', |
|
823
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
447
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', |
|
52 |
{'type' : 'yn', 'default': True, |
|
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', |
|
60 |
{'type' : 'int', 'default': 40, |
|
61 |
'help': _('maximum number of objects displayed by page of results'), |
|
62 |
'group': 'navigation', |
|
63 |
}), |
|
64 |
('related-limit', |
|
65 |
{'type' : 'int', 'default': 8, |
|
66 |
'help': _('maximum number of related entities to display in the primary ' |
|
67 |
'view'), |
|
68 |
'group': 'navigation', |
|
69 |
}), |
|
70 |
('combobox-limit', |
|
71 |
{'type' : 'int', 'default': 20, |
|
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 |
|
0 | 76 |
)) |
77 |
||
78 |
||
79 |
class WebConfiguration(CubicWebConfiguration): |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2267
diff
changeset
|
80 |
"""the WebConfiguration is a singleton object handling instance's |
0 | 81 |
configuration and preferences |
82 |
""" |
|
5500
55a40cc0ab9a
replaced hardcoded 'web/view' by os.path.join('web', 'view') so views path is also valid under windows
egazoni
parents:
5456
diff
changeset
|
83 |
cubicweb_appobject_path = CubicWebConfiguration.cubicweb_appobject_path | set([join('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
|
84 |
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
|
85 |
|
0 | 86 |
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
|
87 |
('repository-uri', |
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 |
{'type' : 'string', |
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 |
'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
|
90 |
'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
|
91 |
'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
|
92 |
}), |
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
|
93 |
|
0 | 94 |
('anonymous-user', |
95 |
{'type' : 'string', |
|
96 |
'default': None, |
|
97 |
'help': 'login of the CubicWeb user account to use for anonymous 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
|
98 |
'group': 'web', 'level': 1, |
0 | 99 |
}), |
100 |
('anonymous-password', |
|
101 |
{'type' : 'string', |
|
102 |
'default': None, |
|
103 |
'help': 'password of the CubicWeb user account to use for anonymous user, ' |
|
104 |
'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
|
105 |
'group': 'web', 'level': 1, |
0 | 106 |
}), |
107 |
('query-log-file', |
|
108 |
{'type' : 'string', |
|
109 |
'default': None, |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2267
diff
changeset
|
110 |
'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
|
111 |
'group': 'web', 'level': 3, |
0 | 112 |
}), |
113 |
# web configuration |
|
8850
4032499c701e
[cwconfig] Add optional configuration param to load a UI cube before other cubes
Rémi Cardona <remi.cardona@logilab.fr>
parents:
8669
diff
changeset
|
114 |
('ui-cube', |
4032499c701e
[cwconfig] Add optional configuration param to load a UI cube before other cubes
Rémi Cardona <remi.cardona@logilab.fr>
parents:
8669
diff
changeset
|
115 |
{'type' : 'string', |
4032499c701e
[cwconfig] Add optional configuration param to load a UI cube before other cubes
Rémi Cardona <remi.cardona@logilab.fr>
parents:
8669
diff
changeset
|
116 |
'default': None, |
4032499c701e
[cwconfig] Add optional configuration param to load a UI cube before other cubes
Rémi Cardona <remi.cardona@logilab.fr>
parents:
8669
diff
changeset
|
117 |
'help': 'the name of the UI cube that will be loaded before all other '\ |
4032499c701e
[cwconfig] Add optional configuration param to load a UI cube before other cubes
Rémi Cardona <remi.cardona@logilab.fr>
parents:
8669
diff
changeset
|
118 |
'cubes. Setting this value to None will instruct cubicweb not to load '\ |
4032499c701e
[cwconfig] Add optional configuration param to load a UI cube before other cubes
Rémi Cardona <remi.cardona@logilab.fr>
parents:
8669
diff
changeset
|
119 |
'any extra cube.', |
4032499c701e
[cwconfig] Add optional configuration param to load a UI cube before other cubes
Rémi Cardona <remi.cardona@logilab.fr>
parents:
8669
diff
changeset
|
120 |
'group': 'web', 'level': 3, |
4032499c701e
[cwconfig] Add optional configuration param to load a UI cube before other cubes
Rémi Cardona <remi.cardona@logilab.fr>
parents:
8669
diff
changeset
|
121 |
}), |
0 | 122 |
('https-url', |
123 |
{'type' : 'string', |
|
124 |
'default': None, |
|
125 |
'help': 'web server root url on https. By specifying this option your '\ |
|
126 |
'site can be available as an http and https site. Authenticated users '\ |
|
127 |
'will in this case be authenticated and once done navigate through the '\ |
|
128 |
'https site. IMPORTANTE NOTE: to do this work, you should have your '\ |
|
129 |
'apache redirection include "https" as base url path so cubicweb can '\ |
|
130 |
'differentiate between http vs https access. For instance: \n'\ |
|
131 |
'RewriteRule ^/demo/(.*) http://127.0.0.1:8080/https/$1 [L,P]\n'\ |
|
132 |
'where the cubicweb web server is listening on port 8080.', |
|
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
133 |
'group': 'main', 'level': 3, |
0 | 134 |
}), |
8149
3ed48646f354
[https] Allow configuration of anonymous access on https (closes #1971992)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7776
diff
changeset
|
135 |
('https-deny-anonymous', |
8186
341c57b39dc9
[config, migration] fix https-deny-anonymous option type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8149
diff
changeset
|
136 |
{'type': 'yn', |
8149
3ed48646f354
[https] Allow configuration of anonymous access on https (closes #1971992)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7776
diff
changeset
|
137 |
'default': False, |
9317
0f2b80078aeb
[web] typo in config file comment
Dimitri Papadopoulos <dimitri.papadopoulos@cea.fr>
parents:
8989
diff
changeset
|
138 |
'help': 'Prevent anonymous user to browse through https version of ' |
8149
3ed48646f354
[https] Allow configuration of anonymous access on https (closes #1971992)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7776
diff
changeset
|
139 |
'the site (https-url). Login form will then be displayed ' |
3ed48646f354
[https] Allow configuration of anonymous access on https (closes #1971992)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7776
diff
changeset
|
140 |
'until logged', |
3ed48646f354
[https] Allow configuration of anonymous access on https (closes #1971992)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7776
diff
changeset
|
141 |
'group': 'web', |
3ed48646f354
[https] Allow configuration of anonymous access on https (closes #1971992)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7776
diff
changeset
|
142 |
'level': 2 |
3ed48646f354
[https] Allow configuration of anonymous access on https (closes #1971992)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7776
diff
changeset
|
143 |
} |
3ed48646f354
[https] Allow configuration of anonymous access on https (closes #1971992)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7776
diff
changeset
|
144 |
), |
0 | 145 |
('auth-mode', |
146 |
{'type' : 'choice', |
|
147 |
'choices' : ('cookie', 'http'), |
|
148 |
'default': 'cookie', |
|
149 |
'help': 'authentication mode (cookie / http)', |
|
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
150 |
'group': 'web', 'level': 3, |
0 | 151 |
}), |
152 |
('realm', |
|
153 |
{'type' : 'string', |
|
154 |
'default': 'cubicweb', |
|
155 |
'help': 'realm to use on HTTP authentication mode', |
|
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
156 |
'group': 'web', 'level': 3, |
0 | 157 |
}), |
158 |
('http-session-time', |
|
5326
0d9054eb3bd1
[config] properly use time type for options representing a time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5283
diff
changeset
|
159 |
{'type' : 'time', |
0 | 160 |
'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
|
161 |
'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
|
162 |
"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
|
163 |
"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
|
164 |
'group': 'web', 'level': 2, |
0 | 165 |
}), |
166 |
('cleanup-anonymous-session-time', |
|
5326
0d9054eb3bd1
[config] properly use time type for options representing a time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5283
diff
changeset
|
167 |
{'type' : 'time', |
0d9054eb3bd1
[config] properly use time type for options representing a time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5283
diff
changeset
|
168 |
'default': '5min', |
5283
9ad0eaa09d34
[config] better *-session-time documentation and usage in session handler
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5005
diff
changeset
|
169 |
'help': 'Same as cleanup-session-time but specific to anonymous ' |
9ad0eaa09d34
[config] better *-session-time documentation and usage in session handler
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5005
diff
changeset
|
170 |
'sessions. You can have a much smaller timeout here since it will be ' |
9ad0eaa09d34
[config] better *-session-time documentation and usage in session handler
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5005
diff
changeset
|
171 |
'transparent to the user. Default to 5min.', |
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
172 |
'group': 'web', 'level': 3, |
0 | 173 |
}), |
174 |
('embed-allowed', |
|
175 |
{'type' : 'regexp', |
|
176 |
'default': None, |
|
177 |
'help': 'regular expression matching URLs that may be embeded. \ |
|
178 |
leave it blank if you don\'t want the embedding feature, or set it to ".*" \ |
|
179 |
if you want to allow everything', |
|
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
180 |
'group': 'web', 'level': 3, |
0 | 181 |
}), |
182 |
('submit-mail', |
|
183 |
{'type' : 'string', |
|
184 |
'default': None, |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2267
diff
changeset
|
185 |
'help': ('Mail used as recipient to report bug in this instance, ' |
0 | 186 |
'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
|
187 |
'group': 'web', 'level': 2, |
0 | 188 |
}), |
189 |
||
190 |
('language-negociation', |
|
191 |
{'type' : 'yn', |
|
192 |
'default': True, |
|
193 |
'help': 'use Accept-Language http header to try to set user '\ |
|
194 |
'interface\'s language according to browser defined preferences', |
|
5323
329b4f6d18b4
[config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5283
diff
changeset
|
195 |
'group': 'web', 'level': 2, |
0 | 196 |
}), |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
197 |
|
0 | 198 |
('print-traceback', |
199 |
{'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
|
200 |
'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
|
201 |
'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
|
202 |
'group': 'web', 'level': 2, |
0 | 203 |
}), |
4595
bb08a75832e6
backport crypto/captcha utilities from the registration cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
204 |
|
bb08a75832e6
backport crypto/captcha utilities from the registration cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
205 |
('captcha-font-file', |
bb08a75832e6
backport crypto/captcha utilities from the registration cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
206 |
{'type' : 'string', |
bb08a75832e6
backport crypto/captcha utilities from the registration cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
207 |
'default': join(CubicWebConfiguration.shared_dir(), 'data', 'porkys.ttf'), |
bb08a75832e6
backport crypto/captcha utilities from the registration cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
208 |
'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
|
209 |
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
|
210 |
'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
|
211 |
}), |
bb08a75832e6
backport crypto/captcha utilities from the registration cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
212 |
('captcha-font-size', |
bb08a75832e6
backport crypto/captcha utilities from the registration cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
213 |
{'type' : 'int', |
bb08a75832e6
backport crypto/captcha utilities from the registration cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
214 |
'default': 25, |
bb08a75832e6
backport crypto/captcha utilities from the registration cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
215 |
'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
|
216 |
have the python imaging library installed to use captcha)', |
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
217 |
'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
|
218 |
}), |
bb08a75832e6
backport crypto/captcha utilities from the registration cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
219 |
|
5510
d3e155cab542
[css] keep old css according to a configuration variable (true by default)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5508
diff
changeset
|
220 |
('use-old-css', |
d3e155cab542
[css] keep old css according to a configuration variable (true by default)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5508
diff
changeset
|
221 |
{'type' : 'yn', |
d3e155cab542
[css] keep old css according to a configuration variable (true by default)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5508
diff
changeset
|
222 |
'default': True, |
d3e155cab542
[css] keep old css according to a configuration variable (true by default)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5508
diff
changeset
|
223 |
'help': 'use cubicweb.old.css instead of 3.9 cubicweb.css', |
d3e155cab542
[css] keep old css according to a configuration variable (true by default)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5508
diff
changeset
|
224 |
'group': 'web', 'level': 2, |
d3e155cab542
[css] keep old css according to a configuration variable (true by default)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5508
diff
changeset
|
225 |
}), |
7762
a3f9ba4d44eb
[web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7380
diff
changeset
|
226 |
('concat-resources', |
a3f9ba4d44eb
[web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7380
diff
changeset
|
227 |
{'type' : 'yn', |
a3f9ba4d44eb
[web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7380
diff
changeset
|
228 |
'default': True, |
a3f9ba4d44eb
[web] add option to make resources-concat optional (implements #1910615)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
7380
diff
changeset
|
229 |
'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
|
230 |
'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
|
231 |
}), |
8601
1a6000ff2080
[web] add a ``anonymize-jsonp-queries`` option in file configuration (closes #2465388)
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
8475
diff
changeset
|
232 |
('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
|
233 |
{'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
|
234 |
'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
|
235 |
'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
|
236 |
'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
|
237 |
}), |
9372
e87a808a4c32
[webctl] Generate static data directory on upgrade (closes #2167873)
Julien Cristau <julien.cristau@logilab.fr>
parents:
9340
diff
changeset
|
238 |
('generate-staticdir', |
e87a808a4c32
[webctl] Generate static data directory on upgrade (closes #2167873)
Julien Cristau <julien.cristau@logilab.fr>
parents:
9340
diff
changeset
|
239 |
{'type': 'yn', |
e87a808a4c32
[webctl] Generate static data directory on upgrade (closes #2167873)
Julien Cristau <julien.cristau@logilab.fr>
parents:
9340
diff
changeset
|
240 |
'default': True, |
e87a808a4c32
[webctl] Generate static data directory on upgrade (closes #2167873)
Julien Cristau <julien.cristau@logilab.fr>
parents:
9340
diff
changeset
|
241 |
'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
|
242 |
'group': 'web', 'level': 2, |
e87a808a4c32
[webctl] Generate static data directory on upgrade (closes #2167873)
Julien Cristau <julien.cristau@logilab.fr>
parents:
9340
diff
changeset
|
243 |
}), |
e87a808a4c32
[webctl] Generate static data directory on upgrade (closes #2167873)
Julien Cristau <julien.cristau@logilab.fr>
parents:
9340
diff
changeset
|
244 |
('staticdir-path', |
e87a808a4c32
[webctl] Generate static data directory on upgrade (closes #2167873)
Julien Cristau <julien.cristau@logilab.fr>
parents:
9340
diff
changeset
|
245 |
{'type': 'string', |
e87a808a4c32
[webctl] Generate static data directory on upgrade (closes #2167873)
Julien Cristau <julien.cristau@logilab.fr>
parents:
9340
diff
changeset
|
246 |
'default': None, |
e87a808a4c32
[webctl] Generate static data directory on upgrade (closes #2167873)
Julien Cristau <julien.cristau@logilab.fr>
parents:
9340
diff
changeset
|
247 |
'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
|
248 |
'group': 'web', 'level': 2, |
e87a808a4c32
[webctl] Generate static data directory on upgrade (closes #2167873)
Julien Cristau <julien.cristau@logilab.fr>
parents:
9340
diff
changeset
|
249 |
}), |
0 | 250 |
)) |
251 |
||
8868
12f29b0ed0bb
[webconfig] explicit some webconfig attribute
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8669
diff
changeset
|
252 |
def __init__(self, *args, **kwargs): |
12f29b0ed0bb
[webconfig] explicit some webconfig attribute
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8669
diff
changeset
|
253 |
super(WebConfiguration, self).__init__(*args, **kwargs) |
12f29b0ed0bb
[webconfig] explicit some webconfig attribute
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8669
diff
changeset
|
254 |
self.uiprops = None |
12f29b0ed0bb
[webconfig] explicit some webconfig attribute
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8669
diff
changeset
|
255 |
self.https_uiprops = None |
12f29b0ed0bb
[webconfig] explicit some webconfig attribute
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8669
diff
changeset
|
256 |
self.datadir_url = None |
12f29b0ed0bb
[webconfig] explicit some webconfig attribute
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8669
diff
changeset
|
257 |
self.https_datadir_url = None |
12f29b0ed0bb
[webconfig] explicit some webconfig attribute
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8669
diff
changeset
|
258 |
|
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
|
259 |
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
|
260 |
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
|
261 |
return False |
c9d18b8dbfea
[webconfig] cleanly handles ``fckeditor_installed`` when no uiprops
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8868
diff
changeset
|
262 |
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
|
263 |
|
7031
a04621040cad
[config refactoring] rename eproperty_definition method to cwproperty_definition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6425
diff
changeset
|
264 |
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
|
265 |
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
|
266 |
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
|
267 |
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
|
268 |
yield key, pdef |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
269 |
|
0 | 270 |
# don't use @cached: we want to be able to disable it while this must still |
271 |
# be cached |
|
272 |
def repository(self, vreg=None): |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2267
diff
changeset
|
273 |
"""return the instance's repository object""" |
0 | 274 |
try: |
275 |
return self.__repo |
|
276 |
except AttributeError: |
|
9504
71a11bca251d
[webconfig] get_repository moved to repoapi
Julien Cristau <julien.cristau@logilab.fr>
parents:
9372
diff
changeset
|
277 |
from cubicweb.repoapi import get_repository |
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
|
278 |
repo = get_repository(config=self, vreg=vreg) |
0 | 279 |
self.__repo = repo |
280 |
return repo |
|
281 |
||
282 |
def vc_config(self): |
|
283 |
return self.repository().get_versions() |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
284 |
|
0 | 285 |
def anonymous_user(self): |
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
|
286 |
"""return a login and password to use for anonymous users. |
8601
1a6000ff2080
[web] add a ``anonymize-jsonp-queries`` option in file configuration (closes #2465388)
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
8475
diff
changeset
|
287 |
|
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
|
288 |
None may be returned for both if anonymous connection is not |
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
|
289 |
allowed or if an empty login is used in configuration |
0 | 290 |
""" |
291 |
try: |
|
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
|
292 |
user = self['anonymous-user'] or None |
0 | 293 |
passwd = self['anonymous-password'] |
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
|
294 |
if user: |
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
|
295 |
user = unicode(user) |
0 | 296 |
except KeyError: |
297 |
user, passwd = None, None |
|
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
|
298 |
except UnicodeDecodeError: |
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
|
299 |
raise ConfigurationError("anonymous information should only contains ascii") |
0 | 300 |
return user, passwd |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
301 |
|
8605
797fc2e2fb78
[web] add a digital signature to error form (closes #2522526)
David Douard <david.douard@logilab.fr>
parents:
8601
diff
changeset
|
302 |
@cachedproperty |
797fc2e2fb78
[web] add a digital signature to error form (closes #2522526)
David Douard <david.douard@logilab.fr>
parents:
8601
diff
changeset
|
303 |
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
|
304 |
"""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
|
305 |
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
|
306 |
""" |
797fc2e2fb78
[web] add a digital signature to error form (closes #2522526)
David Douard <david.douard@logilab.fr>
parents:
8601
diff
changeset
|
307 |
return str(uuid4()) |
797fc2e2fb78
[web] add a digital signature to error form (closes #2522526)
David Douard <david.douard@logilab.fr>
parents:
8601
diff
changeset
|
308 |
|
797fc2e2fb78
[web] add a digital signature to error form (closes #2522526)
David Douard <david.douard@logilab.fr>
parents:
8601
diff
changeset
|
309 |
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
|
310 |
"""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
|
311 |
# hmac.new expect bytes |
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
|
312 |
if isinstance(text, unicode): |
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
|
313 |
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
|
314 |
# 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
|
315 |
# 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
|
316 |
return hmac.new(self._instance_salt, |
797fc2e2fb78
[web] add a digital signature to error form (closes #2522526)
David Douard <david.douard@logilab.fr>
parents:
8601
diff
changeset
|
317 |
text.strip().replace('\r\n', '\n')).hexdigest() |
797fc2e2fb78
[web] add a digital signature to error form (closes #2522526)
David Douard <david.douard@logilab.fr>
parents:
8601
diff
changeset
|
318 |
|
797fc2e2fb78
[web] add a digital signature to error form (closes #2522526)
David Douard <david.douard@logilab.fr>
parents:
8601
diff
changeset
|
319 |
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
|
320 |
"""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
|
321 |
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
|
322 |
|
0 | 323 |
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
|
324 |
"""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
|
325 |
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
|
326 |
""" |
0 | 327 |
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
|
328 |
|
0 | 329 |
def locate_doc_file(self, fname): |
330 |
"""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
|
331 |
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
|
332 |
|
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
|
333 |
@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
|
334 |
def _fs_path_locate(self, rid, rdirectory): |
0 | 335 |
"""return the directory where the given resource may be found""" |
336 |
path = [self.apphome] + self.cubes_path() + [join(self.shared_dir())] |
|
337 |
for directory in path: |
|
338 |
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
|
339 |
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
|
340 |
|
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
|
341 |
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
|
342 |
"""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
|
343 |
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
|
344 |
""" |
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
|
345 |
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
|
346 |
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
|
347 |
return None, None |
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
|
348 |
if rdirectory == 'data' and rid.endswith('.css'): |
5902
c344b3079a2d
[css] old css bw compat with @import in a custom css
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5658
diff
changeset
|
349 |
if self['use-old-css'] and rid == 'cubicweb.css': |
c344b3079a2d
[css] old css bw compat with @import in a custom css
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5658
diff
changeset
|
350 |
# @import('cubicweb.css') in css |
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
|
351 |
rid = 'cubicweb.old.css' |
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
|
352 |
return self.uiprops.process_resource(join(directory, rdirectory), rid), rid |
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
|
353 |
return join(directory, rdirectory), rid |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
354 |
|
0 | 355 |
def locate_all_files(self, rid, rdirectory='wdoc'): |
356 |
"""return all files corresponding to the given resource""" |
|
357 |
path = [self.apphome] + self.cubes_path() + [join(self.shared_dir())] |
|
358 |
for directory in path: |
|
359 |
fpath = join(directory, rdirectory, rid) |
|
360 |
if exists(fpath): |
|
361 |
yield join(fpath) |
|
362 |
||
363 |
def load_configuration(self): |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2267
diff
changeset
|
364 |
"""load instance's configuration files""" |
0 | 365 |
super(WebConfiguration, self).load_configuration() |
366 |
# load external resources definition |
|
367 |
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
|
368 |
self._build_ui_properties() |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
369 |
|
0 | 370 |
def _init_base_url(self): |
371 |
# 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
|
372 |
baseurl = self['base-url'] or self.default_base_url() |
0 | 373 |
if baseurl and baseurl[-1] != '/': |
374 |
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
|
375 |
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
|
376 |
self.global_set_option('base-url', baseurl) |
0 | 377 |
httpsurl = self['https-url'] |
8259
1c5be4a1afd1
[web/config] refactor initialization of the data url
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8186
diff
changeset
|
378 |
data_relpath = self.data_relpath() |
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
|
379 |
if httpsurl: |
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
|
380 |
if httpsurl[-1] != '/': |
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
|
381 |
httpsurl += '/' |
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
|
382 |
if not self.repairing: |
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
|
383 |
self.global_set_option('https-url', httpsurl) |
8259
1c5be4a1afd1
[web/config] refactor initialization of the data url
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8186
diff
changeset
|
384 |
self.https_datadir_url = httpsurl + data_relpath |
1c5be4a1afd1
[web/config] refactor initialization of the data url
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8186
diff
changeset
|
385 |
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
|
386 |
|
1c5be4a1afd1
[web/config] refactor initialization of the data url
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8186
diff
changeset
|
387 |
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
|
388 |
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
|
389 |
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
|
390 |
return 'data/%s/' % self.instance_md5_version() |
0 | 391 |
|
5444
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5443
diff
changeset
|
392 |
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
|
393 |
# 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
|
394 |
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
|
395 |
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
|
396 |
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
|
397 |
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
|
398 |
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
|
399 |
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
|
400 |
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
|
401 |
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
|
402 |
if self['https-url']: |
5934
6ccaaf04cfbc
[web configuration] http/https ui properties should not share the same cache directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5933
diff
changeset
|
403 |
cachedir = join(self.appdatahome, 'uicachehttps') |
6ccaaf04cfbc
[web configuration] http/https ui properties should not share the same cache directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5933
diff
changeset
|
404 |
self.check_writeable_uid_directory(cachedir) |
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
|
405 |
self.https_uiprops = PropertySheet( |
5934
6ccaaf04cfbc
[web configuration] http/https ui properties should not share the same cache directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5933
diff
changeset
|
406 |
cachedir, |
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
|
407 |
data=lambda x: self.https_datadir_url + x, |
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
|
408 |
datadir_url=self.https_datadir_url[:-1]) |
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
|
409 |
self._init_uiprops(self.https_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
|
410 |
|
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
|
411 |
def _init_uiprops(self, uiprops): |
5444
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5443
diff
changeset
|
412 |
libuiprops = join(self.shared_dir(), 'data', '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
|
413 |
uiprops.load(libuiprops) |
0 | 414 |
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
|
415 |
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
|
416 |
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
|
417 |
datadir_url = uiprops.context['datadir_url'] |
9257
ce338133c92c
remove cw 3.9 bw compat (bw compat other than the interface -> adapter changes)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8989
diff
changeset
|
418 |
# pre 3.9 css compat, however the old css still rules |
5510
d3e155cab542
[css] keep old css according to a configuration variable (true by default)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5508
diff
changeset
|
419 |
if self['use-old-css']: |
d3e155cab542
[css] keep old css according to a configuration variable (true by default)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5508
diff
changeset
|
420 |
if (datadir_url+'/cubicweb.css') in uiprops['STYLESHEETS']: |
d3e155cab542
[css] keep old css according to a configuration variable (true by default)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5508
diff
changeset
|
421 |
idx = uiprops['STYLESHEETS'].index(datadir_url+'/cubicweb.css') |
d3e155cab542
[css] keep old css according to a configuration variable (true by default)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5508
diff
changeset
|
422 |
uiprops['STYLESHEETS'][idx] = datadir_url+'/cubicweb.old.css' |
d3e155cab542
[css] keep old css according to a configuration variable (true by default)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5508
diff
changeset
|
423 |
if datadir_url+'/cubicweb.reset.css' in uiprops['STYLESHEETS']: |
d3e155cab542
[css] keep old css according to a configuration variable (true by default)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5508
diff
changeset
|
424 |
uiprops['STYLESHEETS'].remove(datadir_url+'/cubicweb.reset.css') |
5658
7b9553a9db65
[ajax] refactor/cleanup low-level ajax functions
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
5555
diff
changeset
|
425 |
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
|
426 |
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
|
427 |
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
|
428 |
|
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
|
429 |
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
|
430 |
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
|
431 |
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
|
432 |
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
|
433 |
uiprops.load(uipropsfile) |
151
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
434 |
|
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
435 |
# static files handling ################################################### |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
436 |
|
151
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
437 |
@property |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
438 |
def static_directory(self): |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
439 |
return join(self.appdatahome, 'static') |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
440 |
|
151
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
441 |
def static_file_exists(self, rpath): |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
442 |
return exists(join(self.static_directory, rpath)) |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
443 |
|
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
444 |
def static_file_open(self, rpath, mode='wb'): |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
445 |
staticdir = self.static_directory |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
446 |
rdir, filename = split(rpath) |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
447 |
if rdir: |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
448 |
staticdir = join(staticdir, rdir) |
8341
af813e7d5daa
[etwist] fix static directory serving; closes #2174797
Florent Cayré <florent.cayre@gmail.com>
parents:
8186
diff
changeset
|
449 |
if not isdir(staticdir) and 'w' in mode: |
af813e7d5daa
[etwist] fix static directory serving; closes #2174797
Florent Cayré <florent.cayre@gmail.com>
parents:
8186
diff
changeset
|
450 |
os.makedirs(staticdir) |
151
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
451 |
return file(join(staticdir, filename), mode) |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
452 |
|
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
453 |
def static_file_add(self, rpath, data): |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
454 |
stream = self.static_file_open(rpath) |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
455 |
stream.write(data) |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
456 |
stream.close() |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
457 |
|
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
458 |
def static_file_del(self, rpath): |
447 | 459 |
if self.static_file_exists(rpath): |
151
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
460 |
os.remove(join(self.static_directory, rpath)) |
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
|
461 |
|
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
|
462 |
@deprecated('[3.9] use _cw.uiprops.get(rid)') |
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
|
463 |
def has_resource(self, rid): |
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
|
464 |
"""return true if an external resource is defined""" |
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
|
465 |
return bool(self.uiprops.get(rid)) |