author | Nicolas Chauvat <nicolas.chauvat@logilab.fr> |
Fri, 22 May 2009 00:52:18 +0200 | |
branch | stable |
changeset 1900 | 8dd4bb69c73d |
parent 1802 | d628defebc17 |
child 1948 | 887ed691c635 |
permissions | -rw-r--r-- |
369
c8a6edc224bb
new rsetxml view, reusing most code from csvexport view
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
180
diff
changeset
|
1 |
# -*- coding: utf-8 -*- |
0 | 2 |
"""common configuration utilities for cubicweb |
3 |
||
4 |
:organization: Logilab |
|
1187 | 5 |
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
0 | 6 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
1493 | 7 |
|
8 |
.. envvar:: CW_CUBES_PATH |
|
9 |
||
10 |
Augments the default search path for cubes |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1681
diff
changeset
|
11 |
|
0 | 12 |
""" |
13 |
__docformat__ = "restructuredtext en" |
|
14 |
||
15 |
import sys |
|
16 |
import os |
|
17 |
import logging |
|
1015
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
18 |
from os.path import exists, join, expanduser, abspath, normpath, basename, isdir |
0 | 19 |
|
20 |
from logilab.common.decorators import cached |
|
180
8bcebdb5f55d
code moved to logilab.common.logging_ext
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
140
diff
changeset
|
21 |
from logilab.common.logging_ext import set_log_methods, init_log |
0 | 22 |
from logilab.common.configuration import (Configuration, Method, |
23 |
ConfigurationMixIn, merge_options) |
|
24 |
||
25 |
from cubicweb import CW_SOFTWARE_ROOT, CW_MIGRATION_MAP, ConfigurationError |
|
1132 | 26 |
from cubicweb.toolsutils import env_path, create_dir |
0 | 27 |
|
28 |
CONFIGURATIONS = [] |
|
29 |
||
30 |
_ = unicode |
|
31 |
||
32 |
class metaconfiguration(type): |
|
33 |
"""metaclass to automaticaly register configuration""" |
|
34 |
def __new__(mcs, name, bases, classdict): |
|
35 |
cls = super(metaconfiguration, mcs).__new__(mcs, name, bases, classdict) |
|
36 |
if classdict.get('name'): |
|
37 |
CONFIGURATIONS.append(cls) |
|
38 |
return cls |
|
39 |
||
40 |
def configuration_cls(name): |
|
41 |
"""return the configuration class registered with the given name""" |
|
42 |
try: |
|
43 |
return [c for c in CONFIGURATIONS if c.name == name][0] |
|
44 |
except IndexError: |
|
45 |
raise ConfigurationError('no such config %r (check it exists with "cubicweb-ctl list")' % name) |
|
46 |
||
47 |
def possible_configurations(directory): |
|
48 |
"""return a list of installed configurations in a directory |
|
49 |
according to *-ctl files |
|
50 |
""" |
|
51 |
return [name for name in ('repository', 'twisted', 'all-in-one') |
|
52 |
if exists(join(directory, '%s.conf' % name))] |
|
53 |
||
54 |
def guess_configuration(directory): |
|
55 |
"""try to guess the configuration to use for a directory. If multiple |
|
56 |
configurations are found, ConfigurationError is raised |
|
57 |
""" |
|
58 |
modes = possible_configurations(directory) |
|
59 |
if len(modes) != 1: |
|
60 |
raise ConfigurationError('unable to guess configuration from %r %s' |
|
61 |
% (directory, modes)) |
|
62 |
return modes[0] |
|
63 |
||
64 |
||
65 |
# persistent options definition |
|
66 |
PERSISTENT_OPTIONS = ( |
|
67 |
('encoding', |
|
68 |
{'type' : 'string', |
|
69 |
'default': 'UTF-8', |
|
70 |
'help': _('user interface encoding'), |
|
71 |
'group': 'ui', 'sitewide': True, |
|
1446 | 72 |
}), |
0 | 73 |
('language', |
74 |
{'type' : 'string', |
|
75 |
'default': 'en', |
|
76 |
'vocabulary': Method('available_languages'), |
|
77 |
'help': _('language of the user interface'), |
|
1446 | 78 |
'group': 'ui', |
0 | 79 |
}), |
80 |
('date-format', |
|
81 |
{'type' : 'string', |
|
82 |
'default': '%Y/%m/%d', |
|
83 |
'help': _('how to format date in the ui ("man strftime" for format description)'), |
|
1446 | 84 |
'group': 'ui', |
0 | 85 |
}), |
86 |
('datetime-format', |
|
87 |
{'type' : 'string', |
|
88 |
'default': '%Y/%m/%d %H:%M', |
|
89 |
'help': _('how to format date and time in the ui ("man strftime" for format description)'), |
|
1446 | 90 |
'group': 'ui', |
0 | 91 |
}), |
92 |
('time-format', |
|
93 |
{'type' : 'string', |
|
94 |
'default': '%H:%M', |
|
95 |
'help': _('how to format time in the ui ("man strftime" for format description)'), |
|
1446 | 96 |
'group': 'ui', |
0 | 97 |
}), |
98 |
('float-format', |
|
99 |
{'type' : 'string', |
|
100 |
'default': '%.3f', |
|
101 |
'help': _('how to format float numbers in the ui'), |
|
1446 | 102 |
'group': 'ui', |
0 | 103 |
}), |
104 |
('default-text-format', |
|
105 |
{'type' : 'choice', |
|
106 |
'choices': ('text/plain', 'text/rest', 'text/html'), |
|
107 |
'default': 'text/html', # use fckeditor in the web ui |
|
108 |
'help': _('default text format for rich text fields.'), |
|
1446 | 109 |
'group': 'ui', |
0 | 110 |
}), |
111 |
('short-line-size', |
|
112 |
{'type' : 'int', |
|
113 |
'default': 40, |
|
114 |
'help': _('maximum number of characters in short description'), |
|
115 |
'group': 'navigation', |
|
116 |
}), |
|
117 |
) |
|
118 |
||
119 |
def register_persistent_options(options): |
|
120 |
global PERSISTENT_OPTIONS |
|
121 |
PERSISTENT_OPTIONS = merge_options(PERSISTENT_OPTIONS + options) |
|
1446 | 122 |
|
0 | 123 |
CFGTYPE2ETYPE_MAP = { |
124 |
'string': 'String', |
|
125 |
'choice': 'String', |
|
126 |
'yn': 'Boolean', |
|
127 |
'int': 'Int', |
|
128 |
'float' : 'Float', |
|
129 |
} |
|
1446 | 130 |
|
0 | 131 |
class CubicWebNoAppConfiguration(ConfigurationMixIn): |
132 |
"""base class for cubicweb configuration without a specific instance directory |
|
133 |
""" |
|
134 |
__metaclass__ = metaconfiguration |
|
135 |
# to set in concrete configuration |
|
136 |
name = None |
|
137 |
# log messages format (see logging module documentation for available keys) |
|
138 |
log_format = '%(asctime)s - (%(name)s) %(levelname)s: %(message)s' |
|
139 |
# nor remove vobjects based on unused interface |
|
140 |
cleanup_interface_sobjects = True |
|
141 |
||
142 |
if os.environ.get('APYCOT_ROOT'): |
|
143 |
mode = 'test' |
|
144 |
CUBES_DIR = '%(APYCOT_ROOT)s/local/share/cubicweb/cubes/' % os.environ |
|
436 | 145 |
# create __init__ file |
146 |
file(join(CUBES_DIR, '__init__.py'), 'w').close() |
|
0 | 147 |
elif exists(join(CW_SOFTWARE_ROOT, '.hg')): |
148 |
mode = 'dev' |
|
1015
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
149 |
CUBES_DIR = abspath(normpath(join(CW_SOFTWARE_ROOT, '../cubes'))) |
0 | 150 |
else: |
151 |
mode = 'installed' |
|
152 |
CUBES_DIR = '/usr/share/cubicweb/cubes/' |
|
153 |
||
1046
52ee022d87e3
simplify registry options to disable some appobjects to use a single option
sylvain.thenault@logilab.fr
parents:
819
diff
changeset
|
154 |
options = ( |
0 | 155 |
('log-threshold', |
156 |
{'type' : 'string', # XXX use a dedicated type? |
|
157 |
'default': 'ERROR', |
|
158 |
'help': 'server\'s log level', |
|
159 |
'group': 'main', 'inputlevel': 1, |
|
160 |
}), |
|
161 |
# pyro name server |
|
162 |
('pyro-ns-host', |
|
163 |
{'type' : 'string', |
|
378
c0cd7398edff
revert local debug checkin
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
369
diff
changeset
|
164 |
'default': '', |
0 | 165 |
'help': 'Pyro name server\'s host. If not set, will be detected by a \ |
166 |
broadcast query', |
|
167 |
'group': 'pyro-name-server', 'inputlevel': 1, |
|
168 |
}), |
|
169 |
('pyro-ns-port', |
|
170 |
{'type' : 'int', |
|
171 |
'default': None, |
|
172 |
'help': 'Pyro name server\'s listening port. If not set, default \ |
|
173 |
port will be used.', |
|
174 |
'group': 'pyro-name-server', 'inputlevel': 1, |
|
175 |
}), |
|
176 |
('pyro-ns-group', |
|
177 |
{'type' : 'string', |
|
178 |
'default': 'cubicweb', |
|
179 |
'help': 'Pyro name server\'s group where the repository will be \ |
|
180 |
registered.', |
|
181 |
'group': 'pyro-name-server', 'inputlevel': 1, |
|
182 |
}), |
|
183 |
# common configuration options which are potentially required as soon as |
|
184 |
# you're using "base" application objects (ie to really server/web |
|
185 |
# specific) |
|
186 |
('base-url', |
|
187 |
{'type' : 'string', |
|
188 |
'default': None, |
|
189 |
'help': 'web server root url', |
|
190 |
'group': 'main', 'inputlevel': 1, |
|
191 |
}), |
|
1520
b097057e629d
provide an option to substitute the base-url (left-most part) subdomain by the one of the current http query to easy multiple subdomains website management
Florent <florent@secondweb.fr>
parents:
1446
diff
changeset
|
192 |
('use-request-subdomain', |
b097057e629d
provide an option to substitute the base-url (left-most part) subdomain by the one of the current http query to easy multiple subdomains website management
Florent <florent@secondweb.fr>
parents:
1446
diff
changeset
|
193 |
{'type' : 'yn', |
b097057e629d
provide an option to substitute the base-url (left-most part) subdomain by the one of the current http query to easy multiple subdomains website management
Florent <florent@secondweb.fr>
parents:
1446
diff
changeset
|
194 |
'default': None, |
b097057e629d
provide an option to substitute the base-url (left-most part) subdomain by the one of the current http query to easy multiple subdomains website management
Florent <florent@secondweb.fr>
parents:
1446
diff
changeset
|
195 |
'help': ('if set, base-url subdomain is replaced by the request\'s ' |
b097057e629d
provide an option to substitute the base-url (left-most part) subdomain by the one of the current http query to easy multiple subdomains website management
Florent <florent@secondweb.fr>
parents:
1446
diff
changeset
|
196 |
'host, to help managing sites with several subdomains in a ' |
b097057e629d
provide an option to substitute the base-url (left-most part) subdomain by the one of the current http query to easy multiple subdomains website management
Florent <florent@secondweb.fr>
parents:
1446
diff
changeset
|
197 |
'single cubicweb instance'), |
b097057e629d
provide an option to substitute the base-url (left-most part) subdomain by the one of the current http query to easy multiple subdomains website management
Florent <florent@secondweb.fr>
parents:
1446
diff
changeset
|
198 |
'group': 'main', 'inputlevel': 1, |
b097057e629d
provide an option to substitute the base-url (left-most part) subdomain by the one of the current http query to easy multiple subdomains website management
Florent <florent@secondweb.fr>
parents:
1446
diff
changeset
|
199 |
}), |
0 | 200 |
('mangle-emails', |
201 |
{'type' : 'yn', |
|
202 |
'default': False, |
|
203 |
'help': "don't display actual email addresses but mangle them if \ |
|
204 |
this option is set to yes", |
|
205 |
'group': 'email', 'inputlevel': 2, |
|
206 |
}), |
|
1046
52ee022d87e3
simplify registry options to disable some appobjects to use a single option
sylvain.thenault@logilab.fr
parents:
819
diff
changeset
|
207 |
('disable-appobjects', |
52ee022d87e3
simplify registry options to disable some appobjects to use a single option
sylvain.thenault@logilab.fr
parents:
819
diff
changeset
|
208 |
{'type' : 'csv', 'default': (), |
52ee022d87e3
simplify registry options to disable some appobjects to use a single option
sylvain.thenault@logilab.fr
parents:
819
diff
changeset
|
209 |
'help': 'comma separated list of identifiers of application objects (<registry>.<oid>) to disable', |
52ee022d87e3
simplify registry options to disable some appobjects to use a single option
sylvain.thenault@logilab.fr
parents:
819
diff
changeset
|
210 |
'group': 'appobjects', 'inputlevel': 2, |
52ee022d87e3
simplify registry options to disable some appobjects to use a single option
sylvain.thenault@logilab.fr
parents:
819
diff
changeset
|
211 |
}), |
0 | 212 |
) |
213 |
# static and class methods used to get application independant resources ## |
|
1446 | 214 |
|
0 | 215 |
@staticmethod |
216 |
def cubicweb_version(): |
|
217 |
"""return installed cubicweb version""" |
|
218 |
from logilab.common.changelog import Version |
|
219 |
from cubicweb import __pkginfo__ |
|
220 |
version = __pkginfo__.numversion |
|
221 |
assert len(version) == 3, version |
|
222 |
return Version(version) |
|
1446 | 223 |
|
0 | 224 |
@staticmethod |
225 |
def persistent_options_configuration(): |
|
226 |
return Configuration(options=PERSISTENT_OPTIONS) |
|
227 |
||
228 |
@classmethod |
|
229 |
def shared_dir(cls): |
|
230 |
"""return the shared data directory (i.e. directory where standard |
|
231 |
library views and data may be found) |
|
232 |
""" |
|
233 |
if cls.mode in ('dev', 'test') and not os.environ.get('APYCOT_ROOT'): |
|
234 |
return join(CW_SOFTWARE_ROOT, 'web') |
|
1039 | 235 |
return cls.cube_dir('shared') |
1446 | 236 |
|
0 | 237 |
@classmethod |
238 |
def i18n_lib_dir(cls): |
|
239 |
"""return application's i18n directory""" |
|
240 |
if cls.mode in ('dev', 'test') and not os.environ.get('APYCOT_ROOT'): |
|
241 |
return join(CW_SOFTWARE_ROOT, 'i18n') |
|
242 |
return join(cls.shared_dir(), 'i18n') |
|
243 |
||
244 |
@classmethod |
|
245 |
def available_cubes(cls): |
|
1015
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
246 |
cubes = set() |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
247 |
for directory in cls.cubes_search_path(): |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
248 |
for cube in os.listdir(directory): |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
249 |
if isdir(join(directory, cube)) and not cube in ('CVS', '.svn', 'shared', '.hg'): |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
250 |
cubes.add(cube) |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
251 |
return sorted(cubes) |
1446 | 252 |
|
0 | 253 |
@classmethod |
1015
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
254 |
def cubes_search_path(cls): |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
255 |
"""return the path of directories where cubes should be searched""" |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
256 |
path = [] |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
257 |
try: |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
258 |
for directory in os.environ['CW_CUBES_PATH'].split(os.pathsep): |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
259 |
directory = abspath(normpath(directory)) |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
260 |
if exists(directory) and not directory in path: |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
261 |
path.append(directory) |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
262 |
except KeyError: |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
263 |
pass |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
264 |
if not cls.CUBES_DIR in path: |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
265 |
path.append(cls.CUBES_DIR) |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
266 |
return path |
1446 | 267 |
|
0 | 268 |
@classmethod |
269 |
def cube_dir(cls, cube): |
|
270 |
"""return the cube directory for the given cube id, |
|
271 |
raise ConfigurationError if it doesn't exists |
|
272 |
""" |
|
1015
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
273 |
for directory in cls.cubes_search_path(): |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
274 |
cubedir = join(directory, cube) |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
275 |
if exists(cubedir): |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
276 |
return cubedir |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
277 |
raise ConfigurationError('no cube %s in %s' % (cube, cls.cubes_search_path())) |
0 | 278 |
|
279 |
@classmethod |
|
280 |
def cube_migration_scripts_dir(cls, cube): |
|
281 |
"""cube migration scripts directory""" |
|
282 |
return join(cls.cube_dir(cube), 'migration') |
|
1446 | 283 |
|
0 | 284 |
@classmethod |
285 |
def cube_pkginfo(cls, cube): |
|
286 |
"""return the information module for the given cube""" |
|
287 |
cube = CW_MIGRATION_MAP.get(cube, cube) |
|
288 |
try: |
|
289 |
return getattr(__import__('cubes.%s.__pkginfo__' % cube), cube).__pkginfo__ |
|
140
478bdd15bc0e
more error resilient
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
0
diff
changeset
|
290 |
except Exception, ex: |
0 | 291 |
raise ConfigurationError('unable to find packaging information for ' |
140
478bdd15bc0e
more error resilient
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
0
diff
changeset
|
292 |
'cube %s (%s: %s)' % (cube, ex.__class__.__name__, ex)) |
0 | 293 |
|
294 |
@classmethod |
|
295 |
def cube_version(cls, cube): |
|
1446 | 296 |
"""return the version of the cube located in the given directory |
0 | 297 |
""" |
298 |
from logilab.common.changelog import Version |
|
299 |
version = cls.cube_pkginfo(cube).numversion |
|
300 |
assert len(version) == 3, version |
|
301 |
return Version(version) |
|
302 |
||
303 |
@classmethod |
|
304 |
def cube_dependencies(cls, cube): |
|
305 |
"""return cubicweb cubes used by the given cube""" |
|
306 |
return getattr(cls.cube_pkginfo(cube), '__use__', ()) |
|
307 |
||
308 |
@classmethod |
|
309 |
def cube_recommends(cls, cube): |
|
310 |
"""return cubicweb cubes recommended by the given cube""" |
|
311 |
return getattr(cls.cube_pkginfo(cube), '__recommend__', ()) |
|
312 |
||
313 |
@classmethod |
|
314 |
def expand_cubes(cls, cubes): |
|
315 |
"""expand the given list of top level cubes used by adding recursivly |
|
316 |
each cube dependencies |
|
317 |
""" |
|
318 |
cubes = list(cubes) |
|
319 |
todo = cubes[:] |
|
320 |
while todo: |
|
321 |
cube = todo.pop(0) |
|
322 |
for depcube in cls.cube_dependencies(cube): |
|
323 |
if depcube not in cubes: |
|
324 |
depcube = CW_MIGRATION_MAP.get(depcube, depcube) |
|
325 |
cubes.append(depcube) |
|
326 |
todo.append(depcube) |
|
327 |
return cubes |
|
328 |
||
329 |
@classmethod |
|
330 |
def reorder_cubes(cls, cubes): |
|
331 |
"""reorder cubes from the top level cubes to inner dependencies |
|
332 |
cubes |
|
333 |
""" |
|
334 |
from logilab.common.graph import get_cycles |
|
335 |
graph = {} |
|
336 |
for cube in cubes: |
|
337 |
cube = CW_MIGRATION_MAP.get(cube, cube) |
|
338 |
deps = cls.cube_dependencies(cube) + \ |
|
339 |
cls.cube_recommends(cube) |
|
340 |
graph[cube] = set(dep for dep in deps if dep in cubes) |
|
341 |
cycles = get_cycles(graph) |
|
342 |
if cycles: |
|
343 |
cycles = '\n'.join(' -> '.join(cycle) for cycle in cycles) |
|
344 |
raise ConfigurationError('cycles in cubes dependencies: %s' |
|
345 |
% cycles) |
|
346 |
cubes = [] |
|
347 |
while graph: |
|
348 |
# sorted to get predictable results |
|
349 |
for cube, deps in sorted(graph.items()): |
|
350 |
if not deps: |
|
351 |
cubes.append(cube) |
|
352 |
del graph[cube] |
|
353 |
for deps in graph.itervalues(): |
|
354 |
try: |
|
355 |
deps.remove(cube) |
|
356 |
except KeyError: |
|
357 |
continue |
|
358 |
return tuple(reversed(cubes)) |
|
1446 | 359 |
|
0 | 360 |
@classmethod |
361 |
def cls_adjust_sys_path(cls): |
|
362 |
"""update python path if necessary""" |
|
1023
278f997aa257
fix sys.path adjustment
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1015
diff
changeset
|
363 |
cubes_parent_dir = normpath(join(cls.CUBES_DIR, '..')) |
278f997aa257
fix sys.path adjustment
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1015
diff
changeset
|
364 |
if not cubes_parent_dir in sys.path: |
278f997aa257
fix sys.path adjustment
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1015
diff
changeset
|
365 |
sys.path.insert(0, cubes_parent_dir) |
0 | 366 |
try: |
1015
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
367 |
import cubes |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
368 |
cubes.__path__ = cls.cubes_search_path() |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
369 |
except ImportError: |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
370 |
return # cubes dir doesn't exists |
0 | 371 |
|
372 |
@classmethod |
|
373 |
def load_cwctl_plugins(cls): |
|
374 |
from logilab.common.modutils import load_module_from_file |
|
375 |
cls.cls_adjust_sys_path() |
|
376 |
for ctlfile in ('web/webctl.py', 'etwist/twctl.py', |
|
377 |
'server/serverctl.py', 'hercule.py', |
|
378 |
'devtools/devctl.py', 'goa/goactl.py'): |
|
379 |
if exists(join(CW_SOFTWARE_ROOT, ctlfile)): |
|
380 |
load_module_from_file(join(CW_SOFTWARE_ROOT, ctlfile)) |
|
381 |
cls.info('loaded cubicweb-ctl plugin %s', ctlfile) |
|
382 |
for cube in cls.available_cubes(): |
|
1015
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
383 |
pluginfile = join(cls.cube_dir(cube), 'ecplugin.py') |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
384 |
initfile = join(cls.cube_dir(cube), '__init__.py') |
0 | 385 |
if exists(pluginfile): |
386 |
try: |
|
387 |
__import__('cubes.%s.ecplugin' % cube) |
|
388 |
cls.info('loaded cubicweb-ctl plugin from %s', cube) |
|
389 |
except: |
|
390 |
cls.exception('while loading plugin %s', pluginfile) |
|
391 |
elif exists(initfile): |
|
392 |
try: |
|
393 |
__import__('cubes.%s' % cube) |
|
394 |
except: |
|
395 |
cls.exception('while loading cube %s', cube) |
|
396 |
else: |
|
1446 | 397 |
cls.warning('no __init__ file in cube %s', cube) |
0 | 398 |
|
399 |
@classmethod |
|
400 |
def init_available_cubes(cls): |
|
401 |
"""cubes may register some sources (svnfile for instance) in their |
|
402 |
__init__ file, so they should be loaded early in the startup process |
|
403 |
""" |
|
404 |
for cube in cls.available_cubes(): |
|
405 |
try: |
|
406 |
__import__('cubes.%s' % cube) |
|
407 |
except Exception, ex: |
|
408 |
cls.warning("can't init cube %s: %s", cube, ex) |
|
1446 | 409 |
|
0 | 410 |
cubicweb_vobject_path = set(['entities']) |
411 |
cube_vobject_path = set(['entities']) |
|
412 |
||
413 |
@classmethod |
|
414 |
def build_vregistry_path(cls, templpath, evobjpath=None, tvobjpath=None): |
|
415 |
"""given a list of directories, return a list of sub files and |
|
416 |
directories that should be loaded by the application objects registry. |
|
417 |
||
418 |
:param evobjpath: |
|
419 |
optional list of sub-directories (or files without the .py ext) of |
|
420 |
the cubicweb library that should be tested and added to the output list |
|
421 |
if they exists. If not give, default to `cubicweb_vobject_path` class |
|
422 |
attribute. |
|
423 |
:param tvobjpath: |
|
424 |
optional list of sub-directories (or files without the .py ext) of |
|
425 |
directories given in `templpath` that should be tested and added to |
|
426 |
the output list if they exists. If not give, default to |
|
427 |
`cube_vobject_path` class attribute. |
|
428 |
""" |
|
429 |
vregpath = cls.build_vregistry_cubicweb_path(evobjpath) |
|
430 |
vregpath += cls.build_vregistry_cube_path(templpath, tvobjpath) |
|
431 |
return vregpath |
|
432 |
||
433 |
@classmethod |
|
434 |
def build_vregistry_cubicweb_path(cls, evobjpath=None): |
|
435 |
vregpath = [] |
|
436 |
if evobjpath is None: |
|
437 |
evobjpath = cls.cubicweb_vobject_path |
|
438 |
for subdir in evobjpath: |
|
439 |
path = join(CW_SOFTWARE_ROOT, subdir) |
|
440 |
if exists(path): |
|
441 |
vregpath.append(path) |
|
442 |
return vregpath |
|
443 |
||
444 |
@classmethod |
|
445 |
def build_vregistry_cube_path(cls, templpath, tvobjpath=None): |
|
446 |
vregpath = [] |
|
447 |
if tvobjpath is None: |
|
448 |
tvobjpath = cls.cube_vobject_path |
|
449 |
for directory in templpath: |
|
450 |
for subdir in tvobjpath: |
|
451 |
path = join(directory, subdir) |
|
452 |
if exists(path): |
|
453 |
vregpath.append(path) |
|
454 |
elif exists(path + '.py'): |
|
455 |
vregpath.append(path + '.py') |
|
456 |
return vregpath |
|
1446 | 457 |
|
0 | 458 |
def __init__(self): |
459 |
ConfigurationMixIn.__init__(self) |
|
460 |
self.adjust_sys_path() |
|
461 |
self.load_defaults() |
|
1446 | 462 |
self.translations = {} |
0 | 463 |
|
464 |
def adjust_sys_path(self): |
|
465 |
self.cls_adjust_sys_path() |
|
1446 | 466 |
|
467 |
def init_log(self, logthreshold=None, debug=False, |
|
0 | 468 |
logfile=None, syslog=False): |
469 |
"""init the log service""" |
|
180
8bcebdb5f55d
code moved to logilab.common.logging_ext
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
140
diff
changeset
|
470 |
if logthreshold is None: |
0 | 471 |
if debug: |
180
8bcebdb5f55d
code moved to logilab.common.logging_ext
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
140
diff
changeset
|
472 |
logthreshold = 'DEBUG' |
0 | 473 |
else: |
180
8bcebdb5f55d
code moved to logilab.common.logging_ext
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
140
diff
changeset
|
474 |
logthreshold = self['log-threshold'] |
8bcebdb5f55d
code moved to logilab.common.logging_ext
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
140
diff
changeset
|
475 |
init_log(debug, syslog, logthreshold, logfile, self.log_format) |
0 | 476 |
# configure simpleTal logger |
477 |
logging.getLogger('simpleTAL').setLevel(logging.ERROR) |
|
478 |
||
479 |
def vregistry_path(self): |
|
480 |
"""return a list of files or directories where the registry will look |
|
481 |
for application objects. By default return nothing in NoApp config. |
|
482 |
""" |
|
483 |
return [] |
|
1446 | 484 |
|
0 | 485 |
def eproperty_definitions(self): |
486 |
cfg = self.persistent_options_configuration() |
|
487 |
for section, options in cfg.options_by_section(): |
|
488 |
section = section.lower() |
|
489 |
for optname, optdict, value in options: |
|
490 |
key = '%s.%s' % (section, optname) |
|
491 |
type, vocab = self.map_option(optdict) |
|
492 |
default = cfg.option_default(optname, optdict) |
|
493 |
pdef = {'type': type, 'vocabulary': vocab, 'default': default, |
|
494 |
'help': optdict['help'], |
|
495 |
'sitewide': optdict.get('sitewide', False)} |
|
496 |
yield key, pdef |
|
1446 | 497 |
|
0 | 498 |
def map_option(self, optdict): |
499 |
try: |
|
500 |
vocab = optdict['choices'] |
|
501 |
except KeyError: |
|
502 |
vocab = optdict.get('vocabulary') |
|
503 |
if isinstance(vocab, Method): |
|
504 |
vocab = getattr(self, vocab.method, ()) |
|
505 |
return CFGTYPE2ETYPE_MAP[optdict['type']], vocab |
|
506 |
||
1446 | 507 |
|
0 | 508 |
class CubicWebConfiguration(CubicWebNoAppConfiguration): |
509 |
"""base class for cubicweb server and web configurations""" |
|
1446 | 510 |
|
1170
a7c089405185
refactor to avoid having to define CW_INSTANCE_DATA when CW_REGISTRY is set
sylvain.thenault@logilab.fr
parents:
1039
diff
changeset
|
511 |
INSTANCE_DATA_DIR = None |
0 | 512 |
if CubicWebNoAppConfiguration.mode == 'test': |
513 |
root = os.environ['APYCOT_ROOT'] |
|
514 |
REGISTRY_DIR = '%s/etc/cubicweb.d/' % root |
|
515 |
RUNTIME_DIR = '/tmp/' |
|
516 |
MIGRATION_DIR = '%s/local/share/cubicweb/migration/' % root |
|
517 |
if not exists(REGISTRY_DIR): |
|
518 |
os.makedirs(REGISTRY_DIR) |
|
519 |
elif CubicWebNoAppConfiguration.mode == 'dev': |
|
520 |
REGISTRY_DIR = expanduser('~/etc/cubicweb.d/') |
|
521 |
RUNTIME_DIR = '/tmp/' |
|
522 |
MIGRATION_DIR = join(CW_SOFTWARE_ROOT, 'misc', 'migration') |
|
523 |
else: #mode = 'installed' |
|
524 |
REGISTRY_DIR = '/etc/cubicweb.d/' |
|
525 |
INSTANCE_DATA_DIR = '/var/lib/cubicweb/instances/' |
|
526 |
RUNTIME_DIR = '/var/run/cubicweb/' |
|
527 |
MIGRATION_DIR = '/usr/share/cubicweb/migration/' |
|
528 |
||
529 |
# for some commands (creation...) we don't want to initialize gettext |
|
530 |
set_language = True |
|
531 |
# set this to true to avoid false error message while creating an application |
|
532 |
creating = False |
|
1446 | 533 |
|
0 | 534 |
options = CubicWebNoAppConfiguration.options + ( |
535 |
('log-file', |
|
536 |
{'type' : 'string', |
|
537 |
'default': Method('default_log_file'), |
|
538 |
'help': 'file where output logs should be written', |
|
539 |
'group': 'main', 'inputlevel': 2, |
|
540 |
}), |
|
541 |
# email configuration |
|
542 |
('smtp-host', |
|
543 |
{'type' : 'string', |
|
544 |
'default': 'mail', |
|
545 |
'help': 'hostname of the SMTP mail server', |
|
546 |
'group': 'email', 'inputlevel': 1, |
|
547 |
}), |
|
548 |
('smtp-port', |
|
549 |
{'type' : 'int', |
|
550 |
'default': 25, |
|
551 |
'help': 'listening port of the SMTP mail server', |
|
552 |
'group': 'email', 'inputlevel': 1, |
|
553 |
}), |
|
554 |
('sender-name', |
|
555 |
{'type' : 'string', |
|
1446 | 556 |
'default': Method('default_application_id'), |
0 | 557 |
'help': 'name used as HELO name for outgoing emails from the \ |
558 |
repository.', |
|
559 |
'group': 'email', 'inputlevel': 2, |
|
560 |
}), |
|
561 |
('sender-addr', |
|
562 |
{'type' : 'string', |
|
563 |
'default': 'devel@logilab.fr', |
|
564 |
'help': 'email address used as HELO address for outgoing emails from \ |
|
565 |
the repository', |
|
566 |
'group': 'email', 'inputlevel': 1, |
|
567 |
}), |
|
568 |
) |
|
569 |
||
570 |
@classmethod |
|
571 |
def runtime_dir(cls): |
|
572 |
"""run time directory for pid file...""" |
|
573 |
return env_path('CW_RUNTIME', cls.RUNTIME_DIR, 'run time') |
|
1446 | 574 |
|
0 | 575 |
@classmethod |
576 |
def registry_dir(cls): |
|
577 |
"""return the control directory""" |
|
578 |
return env_path('CW_REGISTRY', cls.REGISTRY_DIR, 'registry') |
|
579 |
||
580 |
@classmethod |
|
581 |
def instance_data_dir(cls): |
|
582 |
"""return the instance data directory""" |
|
1170
a7c089405185
refactor to avoid having to define CW_INSTANCE_DATA when CW_REGISTRY is set
sylvain.thenault@logilab.fr
parents:
1039
diff
changeset
|
583 |
return env_path('CW_INSTANCE_DATA', |
a7c089405185
refactor to avoid having to define CW_INSTANCE_DATA when CW_REGISTRY is set
sylvain.thenault@logilab.fr
parents:
1039
diff
changeset
|
584 |
cls.INSTANCE_DATA_DIR or cls.REGISTRY_DIR, |
0 | 585 |
'additional data') |
1446 | 586 |
|
0 | 587 |
@classmethod |
588 |
def migration_scripts_dir(cls): |
|
589 |
"""cubicweb migration scripts directory""" |
|
590 |
return env_path('CW_MIGRATION', cls.MIGRATION_DIR, 'migration') |
|
591 |
||
592 |
@classmethod |
|
593 |
def config_for(cls, appid, config=None): |
|
594 |
"""return a configuration instance for the given application identifier |
|
595 |
""" |
|
596 |
config = config or guess_configuration(cls.application_home(appid)) |
|
597 |
configcls = configuration_cls(config) |
|
598 |
return configcls(appid) |
|
1446 | 599 |
|
0 | 600 |
@classmethod |
601 |
def possible_configurations(cls, appid): |
|
602 |
"""return the name of possible configurations for the given |
|
603 |
application id |
|
604 |
""" |
|
605 |
home = cls.application_home(appid) |
|
606 |
return possible_configurations(home) |
|
1446 | 607 |
|
0 | 608 |
@classmethod |
609 |
def application_home(cls, appid): |
|
610 |
"""return the home directory of the application with the given |
|
611 |
application id |
|
612 |
""" |
|
613 |
home = join(cls.registry_dir(), appid) |
|
614 |
if not exists(home): |
|
615 |
raise ConfigurationError('no such application %s (check it exists with "cubicweb-ctl list")' % appid) |
|
616 |
return home |
|
617 |
||
618 |
MODES = ('common', 'repository', 'Any', 'web') |
|
619 |
MCOMPAT = {'all-in-one': MODES, |
|
620 |
'repository': ('common', 'repository', 'Any'), |
|
621 |
'twisted' : ('common', 'web'),} |
|
622 |
@classmethod |
|
623 |
def accept_mode(cls, mode): |
|
624 |
#assert mode in cls.MODES, mode |
|
625 |
return mode in cls.MCOMPAT[cls.name] |
|
1446 | 626 |
|
0 | 627 |
# default configuration methods ########################################### |
1446 | 628 |
|
0 | 629 |
def default_application_id(self): |
630 |
"""return the application identifier, useful for option which need this |
|
631 |
as default value |
|
632 |
""" |
|
633 |
return self.appid |
|
634 |
||
635 |
def default_log_file(self): |
|
636 |
"""return default path to the log file of the application'server""" |
|
637 |
if self.mode == 'dev': |
|
638 |
basepath = '/tmp/%s-%s' % (basename(self.appid), self.name) |
|
639 |
path = basepath + '.log' |
|
640 |
i = 1 |
|
641 |
while exists(path) and i < 100: # arbitrary limit to avoid infinite loop |
|
642 |
try: |
|
643 |
file(path, 'a') |
|
644 |
break |
|
645 |
except IOError: |
|
646 |
path = '%s-%s.log' % (basepath, i) |
|
647 |
i += 1 |
|
648 |
return path |
|
649 |
return '/var/log/cubicweb/%s-%s.log' % (self.appid, self.name) |
|
1446 | 650 |
|
0 | 651 |
def default_pid_file(self): |
652 |
"""return default path to the pid file of the application'server""" |
|
653 |
return join(self.runtime_dir(), '%s-%s.pid' % (self.appid, self.name)) |
|
1446 | 654 |
|
0 | 655 |
# instance methods used to get application specific resources ############# |
1446 | 656 |
|
0 | 657 |
def __init__(self, appid): |
658 |
self.appid = appid |
|
659 |
CubicWebNoAppConfiguration.__init__(self) |
|
660 |
self._cubes = None |
|
661 |
self._site_loaded = set() |
|
662 |
self.load_file_configuration(self.main_config_file()) |
|
663 |
||
664 |
def adjust_sys_path(self): |
|
665 |
CubicWebNoAppConfiguration.adjust_sys_path(self) |
|
666 |
# adding apphome to python path is not usually necessary in production |
|
667 |
# environments, but necessary for tests |
|
668 |
if self.apphome and not self.apphome in sys.path: |
|
669 |
sys.path.insert(0, self.apphome) |
|
670 |
||
671 |
@property |
|
672 |
def apphome(self): |
|
673 |
return join(self.registry_dir(), self.appid) |
|
1446 | 674 |
|
0 | 675 |
@property |
676 |
def appdatahome(self): |
|
677 |
return join(self.instance_data_dir(), self.appid) |
|
1446 | 678 |
|
0 | 679 |
def init_cubes(self, cubes): |
1681
1586c0ed9a92
nicer assertion message
Graziella Toutoungis <graziella.toutoungis@logilab.fr>
parents:
1521
diff
changeset
|
680 |
assert self._cubes is None, self._cubes |
0 | 681 |
self._cubes = self.reorder_cubes(cubes) |
682 |
# load cubes'__init__.py file first |
|
683 |
for cube in cubes: |
|
684 |
__import__('cubes.%s' % cube) |
|
685 |
self.load_site_cubicweb() |
|
686 |
# reload config file in cases options are defined in cubes __init__ |
|
687 |
# or site_cubicweb files |
|
688 |
self.load_file_configuration(self.main_config_file()) |
|
689 |
# configuration initialization hook |
|
690 |
self.load_configuration() |
|
1446 | 691 |
|
0 | 692 |
def cubes(self): |
693 |
"""return the list of cubes used by this instance |
|
694 |
||
695 |
result is ordered from the top level cubes to inner dependencies |
|
696 |
cubes |
|
697 |
""" |
|
698 |
assert self._cubes is not None |
|
699 |
return self._cubes |
|
1446 | 700 |
|
0 | 701 |
def cubes_path(self): |
702 |
"""return the list of path to cubes used by this instance, from outer |
|
703 |
most to inner most cubes |
|
704 |
""" |
|
705 |
return [self.cube_dir(p) for p in self.cubes()] |
|
706 |
||
707 |
def add_cubes(self, cubes): |
|
708 |
"""add given cubes to the list of used cubes""" |
|
709 |
if not isinstance(cubes, list): |
|
710 |
cubes = list(cubes) |
|
711 |
self._cubes = self.reorder_cubes(list(self._cubes) + cubes) |
|
1446 | 712 |
|
0 | 713 |
def main_config_file(self): |
714 |
"""return application's control configuration file""" |
|
715 |
return join(self.apphome, '%s.conf' % self.name) |
|
1446 | 716 |
|
0 | 717 |
def save(self): |
718 |
"""write down current configuration""" |
|
719 |
self.generate_config(open(self.main_config_file(), 'w')) |
|
720 |
||
721 |
@cached |
|
722 |
def instance_md5_version(self): |
|
723 |
import md5 |
|
724 |
infos = [] |
|
725 |
for pkg in self.cubes(): |
|
726 |
version = self.cube_version(pkg) |
|
727 |
infos.append('%s-%s' % (pkg, version)) |
|
728 |
return md5.new(';'.join(infos)).hexdigest() |
|
1446 | 729 |
|
0 | 730 |
def load_site_cubicweb(self): |
731 |
"""load (web?) application's specific site_cubicweb file""" |
|
732 |
for path in reversed([self.apphome] + self.cubes_path()): |
|
733 |
sitefile = join(path, 'site_cubicweb.py') |
|
734 |
if exists(sitefile) and not sitefile in self._site_loaded: |
|
735 |
self._load_site_cubicweb(sitefile) |
|
736 |
self._site_loaded.add(sitefile) |
|
737 |
else: |
|
738 |
sitefile = join(path, 'site_erudi.py') |
|
739 |
if exists(sitefile) and not sitefile in self._site_loaded: |
|
740 |
self._load_site_cubicweb(sitefile) |
|
741 |
self._site_loaded.add(sitefile) |
|
742 |
self.warning('site_erudi.py is deprecated, should be renamed to site_cubicweb.py') |
|
1446 | 743 |
|
0 | 744 |
def _load_site_cubicweb(self, sitefile): |
745 |
context = {} |
|
746 |
execfile(sitefile, context, context) |
|
747 |
self.info('%s loaded', sitefile) |
|
748 |
# cube specific options |
|
749 |
if context.get('options'): |
|
750 |
self.register_options(context['options']) |
|
751 |
self.load_defaults() |
|
1446 | 752 |
|
0 | 753 |
def load_configuration(self): |
754 |
"""load application's configuration files""" |
|
755 |
super(CubicWebConfiguration, self).load_configuration() |
|
756 |
if self.apphome and self.set_language: |
|
757 |
# init gettext |
|
758 |
self._set_language() |
|
1446 | 759 |
|
0 | 760 |
def init_log(self, logthreshold=None, debug=False, force=False): |
761 |
"""init the log service""" |
|
762 |
if not force and hasattr(self, '_logging_initialized'): |
|
763 |
return |
|
764 |
self._logging_initialized = True |
|
765 |
CubicWebNoAppConfiguration.init_log(self, logthreshold, debug, |
|
766 |
logfile=self.get('log-file')) |
|
767 |
# read a config file if it exists |
|
768 |
logconfig = join(self.apphome, 'logging.conf') |
|
769 |
if exists(logconfig): |
|
770 |
logging.fileConfig(logconfig) |
|
771 |
||
772 |
def available_languages(self, *args): |
|
773 |
"""return available translation for an application, by looking for |
|
774 |
compiled catalog |
|
775 |
||
776 |
take *args to be usable as a vocabulary method |
|
777 |
""" |
|
778 |
from glob import glob |
|
779 |
yield 'en' # ensure 'en' is yielded even if no .mo found |
|
780 |
for path in glob(join(self.apphome, 'i18n', |
|
781 |
'*', 'LC_MESSAGES', 'cubicweb.mo')): |
|
782 |
lang = path.split(os.sep)[-3] |
|
783 |
if lang != 'en': |
|
784 |
yield lang |
|
1446 | 785 |
|
0 | 786 |
def _set_language(self): |
787 |
"""set language for gettext""" |
|
788 |
from gettext import translation |
|
789 |
path = join(self.apphome, 'i18n') |
|
790 |
for language in self.available_languages(): |
|
791 |
self.info("loading language %s", language) |
|
792 |
try: |
|
793 |
tr = translation('cubicweb', path, languages=[language]) |
|
794 |
self.translations[language] = tr.ugettext |
|
795 |
except (ImportError, AttributeError, IOError): |
|
796 |
self.exception('localisation support error for language %s', |
|
1446 | 797 |
language) |
798 |
||
0 | 799 |
def vregistry_path(self): |
800 |
"""return a list of files or directories where the registry will look |
|
801 |
for application objects |
|
802 |
""" |
|
803 |
templpath = list(reversed(self.cubes_path())) |
|
804 |
if self.apphome: # may be unset in tests |
|
805 |
templpath.append(self.apphome) |
|
806 |
return self.build_vregistry_path(templpath) |
|
807 |
||
808 |
def set_sources_mode(self, sources): |
|
809 |
if not 'all' in sources: |
|
810 |
print 'warning: ignoring specified sources, requires a repository '\ |
|
811 |
'configuration' |
|
1446 | 812 |
|
0 | 813 |
def migration_handler(self): |
814 |
"""return a migration handler instance""" |
|
815 |
from cubicweb.common.migration import MigrationHelper |
|
816 |
return MigrationHelper(self, verbosity=self.verbosity) |
|
817 |
||
818 |
def i18ncompile(self, langs=None): |
|
819 |
from cubicweb.common import i18n |
|
820 |
if langs is None: |
|
821 |
langs = self.available_languages() |
|
822 |
i18ndir = join(self.apphome, 'i18n') |
|
823 |
if not exists(i18ndir): |
|
824 |
create_dir(i18ndir) |
|
825 |
sourcedirs = [join(path, 'i18n') for path in self.cubes_path()] |
|
826 |
sourcedirs.append(self.i18n_lib_dir()) |
|
827 |
return i18n.compile_i18n_catalogs(sourcedirs, i18ndir, langs) |
|
828 |
||
180
8bcebdb5f55d
code moved to logilab.common.logging_ext
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
140
diff
changeset
|
829 |
set_log_methods(CubicWebConfiguration, logging.getLogger('cubicweb.configuration')) |
1446 | 830 |
|
0 | 831 |
# alias to get a configuration instance from an application id |
1446 | 832 |
application_configuration = CubicWebConfiguration.config_for |
0 | 833 |