author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Tue, 05 Apr 2011 12:48:53 +0200 | |
changeset 7177 | 0f2905cbe443 |
parent 7130 | 5eb622c0c672 |
child 7275 | bb3bb8104134 |
permissions | -rw-r--r-- |
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
|
1 |
# copyright 2003-2011 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 |
|
1132 | 24 |
from os.path import join, exists, split |
5444
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5443
diff
changeset
|
25 |
from warnings import warn |
0 | 26 |
|
3642 | 27 |
from logilab.common.decorators import cached |
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
|
28 |
from logilab.common.deprecation import deprecated |
0 | 29 |
|
30 |
from cubicweb.toolsutils import read_config |
|
31 |
from cubicweb.cwconfig import CubicWebConfiguration, register_persistent_options, merge_options |
|
32 |
||
33 |
||
34 |
register_persistent_options( ( |
|
35 |
# site-wide only web ui configuration |
|
36 |
('site-title', |
|
37 |
{'type' : 'string', 'default': 'unset title', |
|
38 |
'help': _('site title'), |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
39 |
'sitewide': True, 'group': 'ui', |
0 | 40 |
}), |
41 |
('main-template', |
|
823
cb8ccbef8fa5
main template refactoring
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
447
diff
changeset
|
42 |
{'type' : 'string', 'default': 'main-template', |
0 | 43 |
'help': _('id of main template used to render pages'), |
44 |
'sitewide': True, 'group': 'ui', |
|
45 |
}), |
|
46 |
# user web ui configuration |
|
47 |
('fckeditor', |
|
48 |
{'type' : 'yn', 'default': True, |
|
49 |
'help': _('should html fields being edited using fckeditor (a HTML ' |
|
50 |
'WYSIWYG editor). You should also select text/html as default ' |
|
51 |
'text format to actually get fckeditor.'), |
|
52 |
'group': 'ui', |
|
53 |
}), |
|
54 |
# navigation configuration |
|
55 |
('page-size', |
|
56 |
{'type' : 'int', 'default': 40, |
|
57 |
'help': _('maximum number of objects displayed by page of results'), |
|
58 |
'group': 'navigation', |
|
59 |
}), |
|
60 |
('related-limit', |
|
61 |
{'type' : 'int', 'default': 8, |
|
62 |
'help': _('maximum number of related entities to display in the primary ' |
|
63 |
'view'), |
|
64 |
'group': 'navigation', |
|
65 |
}), |
|
66 |
('combobox-limit', |
|
67 |
{'type' : 'int', 'default': 20, |
|
68 |
'help': _('maximum number of entities to display in related combo box'), |
|
69 |
'group': 'navigation', |
|
70 |
}), |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
71 |
|
0 | 72 |
)) |
73 |
||
74 |
||
75 |
class WebConfiguration(CubicWebConfiguration): |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2267
diff
changeset
|
76 |
"""the WebConfiguration is a singleton object handling instance's |
0 | 77 |
configuration and preferences |
78 |
""" |
|
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
|
79 |
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
|
80 |
cube_appobject_path = CubicWebConfiguration.cube_appobject_path | set(['views']) |
5489
50e2d8e10638
[web config] set default uiprops on web config class to avoid error on commands such as i18n instance
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5473
diff
changeset
|
81 |
uiprops = {'FCKEDITOR_PATH': ''} |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
82 |
|
0 | 83 |
options = merge_options(CubicWebConfiguration.options + ( |
84 |
('anonymous-user', |
|
85 |
{'type' : 'string', |
|
86 |
'default': None, |
|
87 |
'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
|
88 |
'group': 'web', 'level': 1, |
0 | 89 |
}), |
90 |
('anonymous-password', |
|
91 |
{'type' : 'string', |
|
92 |
'default': None, |
|
93 |
'help': 'password of the CubicWeb user account to use for anonymous user, ' |
|
94 |
'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
|
95 |
'group': 'web', 'level': 1, |
0 | 96 |
}), |
97 |
('query-log-file', |
|
98 |
{'type' : 'string', |
|
99 |
'default': None, |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2267
diff
changeset
|
100 |
'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
|
101 |
'group': 'web', 'level': 3, |
0 | 102 |
}), |
103 |
# web configuration |
|
104 |
('https-url', |
|
105 |
{'type' : 'string', |
|
106 |
'default': None, |
|
107 |
'help': 'web server root url on https. By specifying this option your '\ |
|
108 |
'site can be available as an http and https site. Authenticated users '\ |
|
109 |
'will in this case be authenticated and once done navigate through the '\ |
|
110 |
'https site. IMPORTANTE NOTE: to do this work, you should have your '\ |
|
111 |
'apache redirection include "https" as base url path so cubicweb can '\ |
|
112 |
'differentiate between http vs https access. For instance: \n'\ |
|
113 |
'RewriteRule ^/demo/(.*) http://127.0.0.1:8080/https/$1 [L,P]\n'\ |
|
114 |
'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
|
115 |
'group': 'main', 'level': 3, |
0 | 116 |
}), |
117 |
('auth-mode', |
|
118 |
{'type' : 'choice', |
|
119 |
'choices' : ('cookie', 'http'), |
|
120 |
'default': 'cookie', |
|
121 |
'help': 'authentication mode (cookie / http)', |
|
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
122 |
'group': 'web', 'level': 3, |
0 | 123 |
}), |
124 |
('realm', |
|
125 |
{'type' : 'string', |
|
126 |
'default': 'cubicweb', |
|
127 |
'help': 'realm to use on HTTP authentication mode', |
|
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
128 |
'group': 'web', 'level': 3, |
0 | 129 |
}), |
130 |
('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
|
131 |
{'type' : 'time', |
0 | 132 |
'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
|
133 |
'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
|
134 |
"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
|
135 |
"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
|
136 |
'group': 'web', 'level': 2, |
0 | 137 |
}), |
138 |
('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
|
139 |
{'type' : 'time', |
0d9054eb3bd1
[config] properly use time type for options representing a time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5283
diff
changeset
|
140 |
'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
|
141 |
'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
|
142 |
'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
|
143 |
'transparent to the user. Default to 5min.', |
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
144 |
'group': 'web', 'level': 3, |
0 | 145 |
}), |
2552
1ea2f2ff5dca
add force-html-content-type config boolean variable
Florent <florent@secondweb.fr>
parents:
2476
diff
changeset
|
146 |
('force-html-content-type', |
1ea2f2ff5dca
add force-html-content-type config boolean variable
Florent <florent@secondweb.fr>
parents:
2476
diff
changeset
|
147 |
{'type' : 'yn', |
1ea2f2ff5dca
add force-html-content-type config boolean variable
Florent <florent@secondweb.fr>
parents:
2476
diff
changeset
|
148 |
'default': False, |
1ea2f2ff5dca
add force-html-content-type config boolean variable
Florent <florent@secondweb.fr>
parents:
2476
diff
changeset
|
149 |
'help': 'force text/html content type for your html pages instead of cubicweb user-agent based'\ |
1ea2f2ff5dca
add force-html-content-type config boolean variable
Florent <florent@secondweb.fr>
parents:
2476
diff
changeset
|
150 |
'deduction of an appropriate content type', |
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
151 |
'group': 'web', 'level': 3, |
2552
1ea2f2ff5dca
add force-html-content-type config boolean variable
Florent <florent@secondweb.fr>
parents:
2476
diff
changeset
|
152 |
}), |
0 | 153 |
('embed-allowed', |
154 |
{'type' : 'regexp', |
|
155 |
'default': None, |
|
156 |
'help': 'regular expression matching URLs that may be embeded. \ |
|
157 |
leave it blank if you don\'t want the embedding feature, or set it to ".*" \ |
|
158 |
if you want to allow everything', |
|
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
159 |
'group': 'web', 'level': 3, |
0 | 160 |
}), |
161 |
('submit-mail', |
|
162 |
{'type' : 'string', |
|
163 |
'default': None, |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2267
diff
changeset
|
164 |
'help': ('Mail used as recipient to report bug in this instance, ' |
0 | 165 |
'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
|
166 |
'group': 'web', 'level': 2, |
0 | 167 |
}), |
168 |
||
169 |
('language-negociation', |
|
170 |
{'type' : 'yn', |
|
171 |
'default': True, |
|
172 |
'help': 'use Accept-Language http header to try to set user '\ |
|
173 |
'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
|
174 |
'group': 'web', 'level': 2, |
0 | 175 |
}), |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
176 |
|
0 | 177 |
('print-traceback', |
178 |
{'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
|
179 |
'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
|
180 |
'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
|
181 |
'group': 'web', 'level': 2, |
0 | 182 |
}), |
4595
bb08a75832e6
backport crypto/captcha utilities from the registration cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
183 |
|
bb08a75832e6
backport crypto/captcha utilities from the registration cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
184 |
('captcha-font-file', |
bb08a75832e6
backport crypto/captcha utilities from the registration cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
185 |
{'type' : 'string', |
bb08a75832e6
backport crypto/captcha utilities from the registration cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
186 |
'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
|
187 |
'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
|
188 |
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
|
189 |
'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
|
190 |
}), |
bb08a75832e6
backport crypto/captcha utilities from the registration cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
191 |
('captcha-font-size', |
bb08a75832e6
backport crypto/captcha utilities from the registration cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
192 |
{'type' : 'int', |
bb08a75832e6
backport crypto/captcha utilities from the registration cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
193 |
'default': 25, |
bb08a75832e6
backport crypto/captcha utilities from the registration cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
194 |
'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
|
195 |
have the python imaging library installed to use captcha)', |
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
196 |
'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
|
197 |
}), |
bb08a75832e6
backport crypto/captcha utilities from the registration cube
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
198 |
|
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
|
199 |
('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
|
200 |
{'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
|
201 |
'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
|
202 |
'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
|
203 |
'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
|
204 |
}), |
0 | 205 |
)) |
206 |
||
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
|
207 |
def fckeditor_installed(self): |
5444
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5443
diff
changeset
|
208 |
return exists(self.uiprops['FCKEDITOR_PATH']) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
209 |
|
7031
a04621040cad
[config refactoring] rename eproperty_definition method to cwproperty_definition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6425
diff
changeset
|
210 |
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
|
211 |
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
|
212 |
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
|
213 |
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
|
214 |
yield key, pdef |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
215 |
|
0 | 216 |
# method used to connect to the repository: 'inmemory' / 'pyro' |
217 |
# Pyro repository by default |
|
218 |
repo_method = 'pyro' |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
219 |
|
0 | 220 |
# don't use @cached: we want to be able to disable it while this must still |
221 |
# be cached |
|
222 |
def repository(self, vreg=None): |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2267
diff
changeset
|
223 |
"""return the instance's repository object""" |
0 | 224 |
try: |
225 |
return self.__repo |
|
226 |
except AttributeError: |
|
227 |
from cubicweb.dbapi import get_repository |
|
6061
7cb29eab1c9d
[pyro] instance id cleanup, ensure config['pyro-instance-id'] is a fully qualified pyro id on the server side
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5934
diff
changeset
|
228 |
repo = get_repository(self.repo_method, vreg=vreg, config=self) |
0 | 229 |
self.__repo = repo |
230 |
return repo |
|
231 |
||
232 |
def vc_config(self): |
|
233 |
return self.repository().get_versions() |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
234 |
|
0 | 235 |
def anonymous_user(self): |
236 |
"""return a login and password to use for anonymous users. None |
|
237 |
may be returned for both if anonymous connections are not allowed |
|
238 |
""" |
|
239 |
try: |
|
240 |
user = self['anonymous-user'] |
|
241 |
passwd = self['anonymous-password'] |
|
242 |
except KeyError: |
|
243 |
user, passwd = None, None |
|
244 |
if user is not None: |
|
245 |
user = unicode(user) |
|
246 |
return user, passwd |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
247 |
|
0 | 248 |
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
|
249 |
"""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
|
250 |
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
|
251 |
""" |
0 | 252 |
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
|
253 |
|
0 | 254 |
def locate_doc_file(self, fname): |
255 |
"""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
|
256 |
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
|
257 |
|
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
|
258 |
@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
|
259 |
def _fs_path_locate(self, rid, rdirectory): |
0 | 260 |
"""return the directory where the given resource may be found""" |
261 |
path = [self.apphome] + self.cubes_path() + [join(self.shared_dir())] |
|
262 |
for directory in path: |
|
263 |
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
|
264 |
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
|
265 |
|
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
|
266 |
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
|
267 |
"""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
|
268 |
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
|
269 |
""" |
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
|
270 |
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
|
271 |
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
|
272 |
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
|
273 |
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
|
274 |
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
|
275 |
# @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
|
276 |
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
|
277 |
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
|
278 |
return join(directory, rdirectory), rid |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
279 |
|
0 | 280 |
def locate_all_files(self, rid, rdirectory='wdoc'): |
281 |
"""return all files corresponding to the given resource""" |
|
282 |
path = [self.apphome] + self.cubes_path() + [join(self.shared_dir())] |
|
283 |
for directory in path: |
|
284 |
fpath = join(directory, rdirectory, rid) |
|
285 |
if exists(fpath): |
|
286 |
yield join(fpath) |
|
287 |
||
288 |
def load_configuration(self): |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2267
diff
changeset
|
289 |
"""load instance's configuration files""" |
0 | 290 |
super(WebConfiguration, self).load_configuration() |
291 |
# load external resources definition |
|
292 |
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
|
293 |
self._build_ui_properties() |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
294 |
|
0 | 295 |
def _init_base_url(self): |
296 |
# 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
|
297 |
baseurl = self['base-url'] or self.default_base_url() |
0 | 298 |
if baseurl and baseurl[-1] != '/': |
299 |
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
|
300 |
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
|
301 |
self.global_set_option('base-url', baseurl) |
0 | 302 |
httpsurl = self['https-url'] |
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
|
303 |
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
|
304 |
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
|
305 |
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
|
306 |
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
|
307 |
self.global_set_option('https-url', 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
|
308 |
if self.debugmode: |
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
|
309 |
self.https_datadir_url = httpsurl + 'data/' |
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
|
310 |
else: |
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
|
311 |
self.https_datadir_url = httpsurl + 'data%s/' % self.instance_md5_version() |
5444
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5443
diff
changeset
|
312 |
if self.debugmode: |
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5443
diff
changeset
|
313 |
self.datadir_url = baseurl + 'data/' |
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5443
diff
changeset
|
314 |
else: |
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5443
diff
changeset
|
315 |
self.datadir_url = baseurl + 'data%s/' % self.instance_md5_version() |
0 | 316 |
|
5444
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5443
diff
changeset
|
317 |
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
|
318 |
# 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
|
319 |
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
|
320 |
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
|
321 |
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
|
322 |
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
|
323 |
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
|
324 |
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
|
325 |
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
|
326 |
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
|
327 |
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
|
328 |
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
|
329 |
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
|
330 |
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
|
331 |
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
|
332 |
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
|
333 |
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
|
334 |
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
|
335 |
|
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
|
336 |
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
|
337 |
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
|
338 |
uiprops.load(libuiprops) |
0 | 339 |
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
|
340 |
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
|
341 |
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
|
342 |
datadir_url = uiprops.context['datadir_url'] |
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
|
343 |
# XXX pre 3.9 css compat |
d3e155cab542
[css] keep old css according to a configuration variable (true by default)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5508
diff
changeset
|
344 |
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
|
345 |
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
|
346 |
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
|
347 |
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
|
348 |
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
|
349 |
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
|
350 |
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
|
351 |
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
|
352 |
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
|
353 |
|
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
|
354 |
def _load_ui_properties_file(self, uiprops, path): |
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
|
355 |
resourcesfile = join(path, 'data', 'external_resources') |
252
8cd0c2111783
search external_resources in application home
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
151
diff
changeset
|
356 |
if exists(resourcesfile): |
5444
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5443
diff
changeset
|
357 |
warn('[3.9] %s file is deprecated, use an uiprops.py file' |
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5443
diff
changeset
|
358 |
% resourcesfile, DeprecationWarning) |
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
|
359 |
datadir_url = uiprops.context['datadir_url'] |
5444
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5443
diff
changeset
|
360 |
for rid, val in read_config(resourcesfile).iteritems(): |
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5443
diff
changeset
|
361 |
if rid in ('STYLESHEETS', 'STYLESHEETS_PRINT', |
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5443
diff
changeset
|
362 |
'IE_STYLESHEETS', 'JAVASCRIPTS'): |
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
|
363 |
val = [w.strip().replace('DATADIR', datadir_url) |
5444
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5443
diff
changeset
|
364 |
for w in val.split(',') if w.strip()] |
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5443
diff
changeset
|
365 |
if rid == 'IE_STYLESHEETS': |
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5443
diff
changeset
|
366 |
rid = 'STYLESHEETS_IE' |
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5443
diff
changeset
|
367 |
else: |
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
|
368 |
val = val.strip().replace('DATADIR', datadir_url) |
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
|
369 |
uiprops[rid] = val |
5444
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5443
diff
changeset
|
370 |
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
|
371 |
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
|
372 |
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
|
373 |
uiprops.load(uipropsfile) |
151
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
374 |
|
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
375 |
# static files handling ################################################### |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
376 |
|
151
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
377 |
@property |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
378 |
def static_directory(self): |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
379 |
return join(self.appdatahome, 'static') |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1490
diff
changeset
|
380 |
|
151
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
381 |
def static_file_exists(self, rpath): |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
382 |
return exists(join(self.static_directory, rpath)) |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
383 |
|
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
384 |
def static_file_open(self, rpath, mode='wb'): |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
385 |
staticdir = self.static_directory |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
386 |
rdir, filename = split(rpath) |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
387 |
if rdir: |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
388 |
staticdir = join(staticdir, rdir) |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
389 |
os.makedirs(staticdir) |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
390 |
return file(join(staticdir, filename), mode) |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
391 |
|
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
392 |
def static_file_add(self, rpath, data): |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
393 |
stream = self.static_file_open(rpath) |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
394 |
stream.write(data) |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
395 |
stream.close() |
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
396 |
|
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
397 |
def static_file_del(self, rpath): |
447 | 398 |
if self.static_file_exists(rpath): |
151
343e7a18675d
static files support
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
30
diff
changeset
|
399 |
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
|
400 |
|
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
|
401 |
@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
|
402 |
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
|
403 |
"""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
|
404 |
return bool(self.uiprops.get(rid)) |