author | Rémi Cardona <remi.cardona@logilab.fr> |
Fri, 12 Sep 2014 14:10:03 +0200 | |
changeset 9951 | 8cdcbf3f4fd0 |
parent 9891 | 3386fd89c914 |
child 9990 | c84ad981fc4a |
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 -*- |
8544
3d049071957e
massive copyright update to avoid clutering later patches
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8537
diff
changeset
|
2 |
# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5391
diff
changeset
|
3 |
# 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:
5391
diff
changeset
|
4 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5391
diff
changeset
|
5 |
# 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:
5391
diff
changeset
|
6 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5391
diff
changeset
|
7 |
# 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:
5391
diff
changeset
|
8 |
# 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:
5391
diff
changeset
|
9 |
# 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:
5391
diff
changeset
|
10 |
# 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:
5391
diff
changeset
|
11 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
12 |
# 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:
5391
diff
changeset
|
13 |
# 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:
5391
diff
changeset
|
14 |
# 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:
5391
diff
changeset
|
15 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5391
diff
changeset
|
16 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5391
diff
changeset
|
17 |
# 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:
5391
diff
changeset
|
18 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
5135
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
19 |
""" |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
20 |
.. _ResourceMode: |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
21 |
|
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
22 |
Resource mode |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
23 |
------------- |
0 | 24 |
|
8031
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
25 |
Standard resource mode |
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
26 |
``````````````````````````` |
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
27 |
|
6846
4dd1df437e15
[doc] fix typo
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6844
diff
changeset
|
28 |
A resource *mode* is a predefined set of settings for various resources |
5135
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
29 |
directories, such as cubes, instances, etc. to ease development with the |
5264
57ac406d1d82
fix the dosctring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5198
diff
changeset
|
30 |
framework. There are two running modes with *CubicWeb*: |
5135
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
31 |
|
6397
66401ba9332a
[book] improve documentation lisibility for cwconfig chapter and fix some references
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
6192
diff
changeset
|
32 |
* **system**: resources are searched / created in the system directories (eg |
5135
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
33 |
usually requiring root access): |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
34 |
|
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
35 |
- instances are stored in :file:`<INSTALL_PREFIX>/etc/cubicweb.d` |
8031
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
36 |
- temporary files (such as pid file) in :file:`<INSTALL_PREFIX>/var/run/cubicweb` |
5135
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
37 |
|
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
38 |
where `<INSTALL_PREFIX>` is the detected installation prefix ('/usr/local' for |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
39 |
instance). |
1493 | 40 |
|
6397
66401ba9332a
[book] improve documentation lisibility for cwconfig chapter and fix some references
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
6192
diff
changeset
|
41 |
* **user**: resources are searched / created in the user home directory: |
66401ba9332a
[book] improve documentation lisibility for cwconfig chapter and fix some references
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
6192
diff
changeset
|
42 |
|
66401ba9332a
[book] improve documentation lisibility for cwconfig chapter and fix some references
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
6192
diff
changeset
|
43 |
- instances are stored in :file:`~/etc/cubicweb.d` |
66401ba9332a
[book] improve documentation lisibility for cwconfig chapter and fix some references
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
6192
diff
changeset
|
44 |
- temporary files (such as pid file) in :file:`/tmp` |
66401ba9332a
[book] improve documentation lisibility for cwconfig chapter and fix some references
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
6192
diff
changeset
|
45 |
|
66401ba9332a
[book] improve documentation lisibility for cwconfig chapter and fix some references
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
6192
diff
changeset
|
46 |
|
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:
3564
diff
changeset
|
47 |
|
8031
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
48 |
|
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
49 |
.. _CubicwebWithinVirtualEnv: |
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
50 |
|
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
51 |
Within virtual environment |
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
52 |
``````````````````````````` |
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
53 |
|
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
54 |
If you are not administrator of you machine or if you need to play with some |
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
55 |
specific version of |cubicweb| you can use `virtualenv`_ a tool to create |
9257
ce338133c92c
remove cw 3.9 bw compat (bw compat other than the interface -> adapter changes)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9255
diff
changeset
|
56 |
isolated Python environments. |
8031
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
57 |
|
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
58 |
- instances are stored in :file:`<VIRTUAL_ENV>/etc/cubicweb.d` |
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
59 |
- temporary files (such as pid file) in :file:`<VIRTUAL_ENV>/var/run/cubicweb` |
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
60 |
|
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
61 |
.. _`virtualenv`: http://pypi.python.org/pypi/virtualenv |
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
62 |
|
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
63 |
Custom resource location |
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
64 |
```````````````````````````````` |
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
65 |
|
5135
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
66 |
Notice that each resource path may be explicitly set using an environment |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
67 |
variable if the default doesn't suit your needs. Here are the default resource |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
68 |
directories that are affected according to mode: |
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:
3564
diff
changeset
|
69 |
|
6397
66401ba9332a
[book] improve documentation lisibility for cwconfig chapter and fix some references
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
6192
diff
changeset
|
70 |
* **system**: :: |
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:
3564
diff
changeset
|
71 |
|
5135
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
72 |
CW_INSTANCES_DIR = <INSTALL_PREFIX>/etc/cubicweb.d/ |
8031
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
73 |
CW_INSTANCES_DATA_DIR = <INSTALL_PREFIX>/var/lib/cubicweb/instances/ |
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
74 |
CW_RUNTIME_DIR = <INSTALL_PREFIX>/var/run/cubicweb/ |
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:
3564
diff
changeset
|
75 |
|
6397
66401ba9332a
[book] improve documentation lisibility for cwconfig chapter and fix some references
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
6192
diff
changeset
|
76 |
* **user**: :: |
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:
3564
diff
changeset
|
77 |
|
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:
3564
diff
changeset
|
78 |
CW_INSTANCES_DIR = ~/etc/cubicweb.d/ |
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:
3564
diff
changeset
|
79 |
CW_INSTANCES_DATA_DIR = ~/etc/cubicweb.d/ |
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:
3564
diff
changeset
|
80 |
CW_RUNTIME_DIR = /tmp |
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:
3564
diff
changeset
|
81 |
|
6397
66401ba9332a
[book] improve documentation lisibility for cwconfig chapter and fix some references
Stephanie Marcu <stephanie.marcu@logilab.fr>
parents:
6192
diff
changeset
|
82 |
Cubes search path is also affected, see the :ref:`Cube` section. |
5135
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
83 |
|
8031
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
84 |
Setting Cubicweb Mode |
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
85 |
````````````````````` |
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
86 |
|
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
87 |
By default, the mode is set to 'system' for standard installation. The mode is |
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
88 |
set to 'user' if `cubicweb is used from a mercurial repository`_. You can force |
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
89 |
this by setting the :envvar:`CW_MODE` environment variable to either 'user' or |
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
90 |
'system' so you can easily: |
5135
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
91 |
|
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
92 |
* use system wide installation but user specific instances and all, without root |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
93 |
privileges on the system (`export CW_MODE=user`) |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
94 |
|
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
95 |
* use local checkout of cubicweb on system wide instances (requires root |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
96 |
privileges on the system (`export CW_MODE=system`) |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
97 |
|
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
98 |
If you've a doubt about the mode you're currently running, check the first line |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
99 |
outputed by the :command:`cubicweb-ctl list` command. |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
100 |
|
8031
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
101 |
.. _`cubicweb is used from a mercurial repository`: CubicwebDevelopmentMod_ |
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
102 |
|
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
103 |
.. _CubicwebDevelopmentMod: |
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
104 |
|
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
105 |
Development Mode |
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
106 |
````````````````````` |
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
107 |
If :file:`.hg` directory is found into the cubicweb package, there are specific resource rules. |
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
108 |
|
dcc2b6a517a0
Update documentation about resource mode.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7879
diff
changeset
|
109 |
`<CW_SOFTWARE_ROOT>` is the mercurial checkout of cubicweb: |
5135
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
110 |
|
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
111 |
* main cubes directory is `<CW_SOFTWARE_ROOT>/../cubes`. You can specify |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
112 |
another one with :envvar:`CW_INSTANCES_DIR` environment variable or simply |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
113 |
add some other directories by using :envvar:`CW_CUBES_PATH` |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
114 |
|
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
115 |
* cubicweb migration files are searched in `<CW_SOFTWARE_ROOT>/misc/migration` |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
116 |
instead of `<INSTALL_PREFIX>/share/cubicweb/migration/`. |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
117 |
|
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
118 |
|
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
119 |
.. _ConfigurationEnv: |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
120 |
|
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
121 |
Environment configuration |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
122 |
------------------------- |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
123 |
|
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
124 |
Python |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
125 |
`````` |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
126 |
|
5264
57ac406d1d82
fix the dosctring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5198
diff
changeset
|
127 |
If you installed *CubicWeb* by cloning the Mercurial forest or from source |
5135
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
128 |
distribution, then you will need to update the environment variable PYTHONPATH by |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
129 |
adding the path to the forest `cubicweb`: |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
130 |
|
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
131 |
Add the following lines to either :file:`.bashrc` or :file:`.bash_profile` to |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
132 |
configure your development environment :: |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
133 |
|
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
134 |
export PYTHONPATH=/full/path/to/cubicweb-forest |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
135 |
|
5264
57ac406d1d82
fix the dosctring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5198
diff
changeset
|
136 |
If you installed *CubicWeb* with packages, no configuration is required and your |
5135
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
137 |
new cubes will be placed in `/usr/share/cubicweb/cubes` and your instances will |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
138 |
be placed in `/etc/cubicweb.d`. |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
139 |
|
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
140 |
|
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
141 |
CubicWeb |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
142 |
```````` |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
143 |
|
5264
57ac406d1d82
fix the dosctring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5198
diff
changeset
|
144 |
Here are all environment variables that may be used to configure *CubicWeb*: |
3639 | 145 |
|
146 |
.. envvar:: CW_MODE |
|
5135
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
147 |
|
5264
57ac406d1d82
fix the dosctring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5198
diff
changeset
|
148 |
Resource mode: user or system, as explained in :ref:`ResourceMode`. |
3639 | 149 |
|
1493 | 150 |
.. envvar:: CW_CUBES_PATH |
5135
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
151 |
|
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
152 |
Augments the default search path for cubes. You may specify several |
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
153 |
directories using ':' as separator (';' under windows environment). |
3639 | 154 |
|
155 |
.. envvar:: CW_INSTANCES_DIR |
|
5135
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
156 |
|
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
157 |
Directory where cubicweb instances will be found. |
1493 | 158 |
|
3639 | 159 |
.. envvar:: CW_INSTANCES_DATA_DIR |
5135
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
160 |
|
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
161 |
Directory where cubicweb instances data will be written (backup file...) |
3639 | 162 |
|
163 |
.. envvar:: CW_RUNTIME_DIR |
|
5135
f15286235aef
[doc] enhanced setup section: fix sections'level, more postgres tips, merge environment doc with cwconfig.py module docstring using custom autodocstring directive
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5086
diff
changeset
|
164 |
|
3639 | 165 |
Directory where pid files will be written |
0 | 166 |
""" |
5885
5d908f1a7659
[config] use hashlib to avoid warning w/ py2.6
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5817
diff
changeset
|
167 |
|
0 | 168 |
__docformat__ = "restructuredtext en" |
1948 | 169 |
_ = unicode |
0 | 170 |
|
171 |
import sys |
|
172 |
import os |
|
8484
4c1efb5bde0a
[config] load_configuration should not crash because of fs errors. Closes #2286215
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8477
diff
changeset
|
173 |
import stat |
0 | 174 |
import logging |
7178
a62f24e1497e
fileConfig is in logging.config
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7086
diff
changeset
|
175 |
import logging.config |
2221
d9b85a7b0bdd
create sendmails method on cwconfig, use it in SendMailOp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2220
diff
changeset
|
176 |
from smtplib import SMTP |
d9b85a7b0bdd
create sendmails method on cwconfig, use it in SendMailOp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2220
diff
changeset
|
177 |
from threading import Lock |
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
178 |
from os.path import (exists, join, expanduser, abspath, normpath, |
6749
48f468f33704
[config, i18n] Create default translation mechanism for all supported languages.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6748
diff
changeset
|
179 |
basename, isdir, dirname, splitext) |
7822
ce8a4de2ecf1
[warnings] explicitly ask to show DeprecationWarning in debug mode (closes #1942760)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7815
diff
changeset
|
180 |
from warnings import warn, filterwarnings |
ce8a4de2ecf1
[warnings] explicitly ask to show DeprecationWarning in debug mode (closes #1942760)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7815
diff
changeset
|
181 |
|
4323
aae19998dd93
move extra path computing as a configuration class property so we can reused it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4322
diff
changeset
|
182 |
from logilab.common.decorators import cached, classproperty |
2613
5e19c2bb370e
R [all] logilab.common 0.44 provides only deprecated
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2476
diff
changeset
|
183 |
from logilab.common.deprecation import deprecated |
180
8bcebdb5f55d
code moved to logilab.common.logging_ext
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
140
diff
changeset
|
184 |
from logilab.common.logging_ext import set_log_methods, init_log |
0 | 185 |
from logilab.common.configuration import (Configuration, Method, |
186 |
ConfigurationMixIn, merge_options) |
|
187 |
||
5013
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4938
diff
changeset
|
188 |
from cubicweb import (CW_SOFTWARE_ROOT, CW_MIGRATION_MAP, |
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4938
diff
changeset
|
189 |
ConfigurationError, Binary) |
6495
3187112bc7cc
#1251878: Cubicweb no longer crash for missing instance and data dir at create.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6192
diff
changeset
|
190 |
from cubicweb.toolsutils import create_dir |
0 | 191 |
|
192 |
CONFIGURATIONS = [] |
|
193 |
||
2221
d9b85a7b0bdd
create sendmails method on cwconfig, use it in SendMailOp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2220
diff
changeset
|
194 |
SMTP_LOCK = Lock() |
d9b85a7b0bdd
create sendmails method on cwconfig, use it in SendMailOp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2220
diff
changeset
|
195 |
|
0 | 196 |
|
197 |
def configuration_cls(name): |
|
198 |
"""return the configuration class registered with the given name""" |
|
199 |
try: |
|
200 |
return [c for c in CONFIGURATIONS if c.name == name][0] |
|
201 |
except IndexError: |
|
202 |
raise ConfigurationError('no such config %r (check it exists with "cubicweb-ctl list")' % name) |
|
203 |
||
204 |
def possible_configurations(directory): |
|
205 |
"""return a list of installed configurations in a directory |
|
4936
a4b772a0d801
Fixed some of the documentation warnings when building the book with sphinx.
Adrien Chauve <adrien.chauve@logilab.fr>
parents:
4889
diff
changeset
|
206 |
according to \*-ctl files |
0 | 207 |
""" |
9251
e4d753c8b1c4
remove "twisted" configuration (closes #2919310)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8850
diff
changeset
|
208 |
return [name for name in ('repository', 'all-in-one') |
0 | 209 |
if exists(join(directory, '%s.conf' % name))] |
210 |
||
211 |
def guess_configuration(directory): |
|
212 |
"""try to guess the configuration to use for a directory. If multiple |
|
213 |
configurations are found, ConfigurationError is raised |
|
214 |
""" |
|
215 |
modes = possible_configurations(directory) |
|
216 |
if len(modes) != 1: |
|
217 |
raise ConfigurationError('unable to guess configuration from %r %s' |
|
218 |
% (directory, modes)) |
|
219 |
return modes[0] |
|
220 |
||
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
221 |
def _find_prefix(start_path=CW_SOFTWARE_ROOT): |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
222 |
"""Runs along the parent directories of *start_path* (default to cubicweb source directory) |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
223 |
looking for one containing a 'share/cubicweb' directory. |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
224 |
The first matching directory is assumed as the prefix installation of cubicweb |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
225 |
|
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
226 |
Returns the matching prefix or None. |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
227 |
""" |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
228 |
prefix = start_path |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
229 |
old_prefix = None |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
230 |
if not isdir(start_path): |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
231 |
prefix = dirname(start_path) |
6503
0fd079726606
[packaging] Egg are not valid cubicweb prefix.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6502
diff
changeset
|
232 |
while (not isdir(join(prefix, 'share', 'cubicweb')) |
0fd079726606
[packaging] Egg are not valid cubicweb prefix.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6502
diff
changeset
|
233 |
or prefix.endswith('.egg')) and prefix != old_prefix: |
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
234 |
old_prefix = prefix |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
235 |
prefix = dirname(prefix) |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
236 |
if isdir(join(prefix, 'share', 'cubicweb')): |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
237 |
return prefix |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
238 |
return sys.prefix |
0 | 239 |
|
240 |
# persistent options definition |
|
241 |
PERSISTENT_OPTIONS = ( |
|
242 |
('encoding', |
|
243 |
{'type' : 'string', |
|
244 |
'default': 'UTF-8', |
|
245 |
'help': _('user interface encoding'), |
|
246 |
'group': 'ui', 'sitewide': True, |
|
1446 | 247 |
}), |
0 | 248 |
('language', |
249 |
{'type' : 'string', |
|
250 |
'default': 'en', |
|
251 |
'vocabulary': Method('available_languages'), |
|
252 |
'help': _('language of the user interface'), |
|
1446 | 253 |
'group': 'ui', |
0 | 254 |
}), |
255 |
('date-format', |
|
256 |
{'type' : 'string', |
|
257 |
'default': '%Y/%m/%d', |
|
8114
8311cc3b472a
Link to python docs about strftime instead of pointing at "man" (closes #2106415)
Julien Cristau <julien.cristau@logilab.fr>
parents:
8049
diff
changeset
|
258 |
'help': _('how to format date in the ui (see <a href="http://docs.python.org/library/datetime.html#strftime-strptime-behavior">this page</a> for format description)'), |
1446 | 259 |
'group': 'ui', |
0 | 260 |
}), |
261 |
('datetime-format', |
|
262 |
{'type' : 'string', |
|
263 |
'default': '%Y/%m/%d %H:%M', |
|
8114
8311cc3b472a
Link to python docs about strftime instead of pointing at "man" (closes #2106415)
Julien Cristau <julien.cristau@logilab.fr>
parents:
8049
diff
changeset
|
264 |
'help': _('how to format date and time in the ui (see <a href="http://docs.python.org/library/datetime.html#strftime-strptime-behavior">this page</a> for format description)'), |
1446 | 265 |
'group': 'ui', |
0 | 266 |
}), |
267 |
('time-format', |
|
268 |
{'type' : 'string', |
|
269 |
'default': '%H:%M', |
|
8114
8311cc3b472a
Link to python docs about strftime instead of pointing at "man" (closes #2106415)
Julien Cristau <julien.cristau@logilab.fr>
parents:
8049
diff
changeset
|
270 |
'help': _('how to format time in the ui (see <a href="http://docs.python.org/library/datetime.html#strftime-strptime-behavior">this page</a> for format description)'), |
1446 | 271 |
'group': 'ui', |
0 | 272 |
}), |
273 |
('float-format', |
|
274 |
{'type' : 'string', |
|
275 |
'default': '%.3f', |
|
276 |
'help': _('how to format float numbers in the ui'), |
|
1446 | 277 |
'group': 'ui', |
0 | 278 |
}), |
279 |
('default-text-format', |
|
280 |
{'type' : 'choice', |
|
281 |
'choices': ('text/plain', 'text/rest', 'text/html'), |
|
282 |
'default': 'text/html', # use fckeditor in the web ui |
|
283 |
'help': _('default text format for rich text fields.'), |
|
1446 | 284 |
'group': 'ui', |
0 | 285 |
}), |
286 |
('short-line-size', |
|
287 |
{'type' : 'int', |
|
5391
fe3fe2b2b60a
[config] augment default value for short-line-size
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5264
diff
changeset
|
288 |
'default': 80, |
0 | 289 |
'help': _('maximum number of characters in short description'), |
290 |
'group': 'navigation', |
|
291 |
}), |
|
292 |
) |
|
293 |
||
294 |
def register_persistent_options(options): |
|
295 |
global PERSISTENT_OPTIONS |
|
296 |
PERSISTENT_OPTIONS = merge_options(PERSISTENT_OPTIONS + options) |
|
1446 | 297 |
|
0 | 298 |
CFGTYPE2ETYPE_MAP = { |
299 |
'string': 'String', |
|
300 |
'choice': 'String', |
|
301 |
'yn': 'Boolean', |
|
302 |
'int': 'Int', |
|
303 |
'float' : 'Float', |
|
304 |
} |
|
1446 | 305 |
|
3059
1be8bf42bc5d
consider CW_MODE='system', the opposite of 'user' (eg use 'installed' mode while using the forest)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2762
diff
changeset
|
306 |
_forced_mode = os.environ.get('CW_MODE') |
1be8bf42bc5d
consider CW_MODE='system', the opposite of 'user' (eg use 'installed' mode while using the forest)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2762
diff
changeset
|
307 |
assert _forced_mode in (None, 'system', 'user') |
1be8bf42bc5d
consider CW_MODE='system', the opposite of 'user' (eg use 'installed' mode while using the forest)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2762
diff
changeset
|
308 |
|
8477
42e8755b3aba
[config] Set CWDEV, aka dev mode, according to presence of the i18n directory, not .hg
Julien Cristau <julien.cristau@logilab.fr>
parents:
8436
diff
changeset
|
309 |
#Â CWDEV tells whether directories such as i18n/, web/data/, etc. (ie containing |
42e8755b3aba
[config] Set CWDEV, aka dev mode, according to presence of the i18n directory, not .hg
Julien Cristau <julien.cristau@logilab.fr>
parents:
8436
diff
changeset
|
310 |
# some other resources than python libraries) are located with the python code |
42e8755b3aba
[config] Set CWDEV, aka dev mode, according to presence of the i18n directory, not .hg
Julien Cristau <julien.cristau@logilab.fr>
parents:
8436
diff
changeset
|
311 |
# or as a 'shared' cube |
42e8755b3aba
[config] Set CWDEV, aka dev mode, according to presence of the i18n directory, not .hg
Julien Cristau <julien.cristau@logilab.fr>
parents:
8436
diff
changeset
|
312 |
CWDEV = exists(join(CW_SOFTWARE_ROOT, 'i18n')) |
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:
3564
diff
changeset
|
313 |
|
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
314 |
try: |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
315 |
_INSTALL_PREFIX = os.environ['CW_INSTALL_PREFIX'] |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
316 |
except KeyError: |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
317 |
_INSTALL_PREFIX = _find_prefix() |
6502
1e1de0339a95
[config] Put "Instance" and "Instance data" directory within cubiweb install prefix.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6495
diff
changeset
|
318 |
_USR_INSTALL = _INSTALL_PREFIX == '/usr' |
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
319 |
|
0 | 320 |
class CubicWebNoAppConfiguration(ConfigurationMixIn): |
321 |
"""base class for cubicweb configuration without a specific instance directory |
|
322 |
""" |
|
323 |
# to set in concrete configuration |
|
324 |
name = None |
|
325 |
# log messages format (see logging module documentation for available keys) |
|
326 |
log_format = '%(asctime)s - (%(name)s) %(levelname)s: %(message)s' |
|
5640
8a6d14f4fb9d
logging settings
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5456
diff
changeset
|
327 |
# the format below can be useful to debug multi thread issues: |
8a6d14f4fb9d
logging settings
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5456
diff
changeset
|
328 |
# log_format = '%(asctime)s - [%(threadName)s] (%(name)s) %(levelname)s: %(message)s' |
8a6d14f4fb9d
logging settings
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5456
diff
changeset
|
329 |
# nor remove appobjects based on unused interface [???] |
9258
4e79f587c6ab
Rename cleanup_interface_sobjects into cleanup_unused_appobjects
Julien Cristau <julien.cristau@logilab.fr>
parents:
9257
diff
changeset
|
330 |
cleanup_unused_appobjects = True |
0 | 331 |
|
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
332 |
if (CWDEV and _forced_mode != 'system'): |
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:
3564
diff
changeset
|
333 |
mode = 'user' |
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
334 |
_CUBES_DIR = join(CW_SOFTWARE_ROOT, '../cubes') |
0 | 335 |
else: |
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
336 |
mode = _forced_mode or 'system' |
5022
7e09702aa766
fix _cubes dir
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5021
diff
changeset
|
337 |
_CUBES_DIR = join(_INSTALL_PREFIX, 'share', 'cubicweb', 'cubes') |
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
338 |
|
6495
3187112bc7cc
#1251878: Cubicweb no longer crash for missing instance and data dir at create.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6192
diff
changeset
|
339 |
CUBES_DIR = abspath(os.environ.get('CW_CUBES_DIR', _CUBES_DIR)) |
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
340 |
CUBES_PATH = os.environ.get('CW_CUBES_PATH', '').split(os.pathsep) |
0 | 341 |
|
1046
52ee022d87e3
simplify registry options to disable some appobjects to use a single option
sylvain.thenault@logilab.fr
parents:
819
diff
changeset
|
342 |
options = ( |
0 | 343 |
('log-threshold', |
344 |
{'type' : 'string', # XXX use a dedicated type? |
|
4624
1b46d5ece0d5
turn default logging threshold to warning (we usually want them), and log 'no schema for eid' pb using warning instead of error, so we see them in logs but not during migration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4606
diff
changeset
|
345 |
'default': 'WARNING', |
0 | 346 |
'help': 'server\'s log level', |
5323
329b4f6d18b4
[config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5322
diff
changeset
|
347 |
'group': 'main', 'level': 1, |
0 | 348 |
}), |
6779
accf5978a440
[daemon] make process umask configurable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6750
diff
changeset
|
349 |
('umask', |
accf5978a440
[daemon] make process umask configurable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6750
diff
changeset
|
350 |
{'type' : 'int', |
accf5978a440
[daemon] make process umask configurable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6750
diff
changeset
|
351 |
'default': 077, |
accf5978a440
[daemon] make process umask configurable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6750
diff
changeset
|
352 |
'help': 'permission umask for files created by the server', |
accf5978a440
[daemon] make process umask configurable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6750
diff
changeset
|
353 |
'group': 'main', 'level': 2, |
accf5978a440
[daemon] make process umask configurable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6750
diff
changeset
|
354 |
}), |
0 | 355 |
# common configuration options which are potentially required as soon as |
356 |
# you're using "base" application objects (ie to really server/web |
|
357 |
# specific) |
|
358 |
('base-url', |
|
359 |
{'type' : 'string', |
|
360 |
'default': None, |
|
361 |
'help': 'web server root url', |
|
5323
329b4f6d18b4
[config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5322
diff
changeset
|
362 |
'group': 'main', 'level': 1, |
0 | 363 |
}), |
2267
e1d2df3f1091
move login by email functionnality on the repository side to avoid buggy call to internal_session from the web interface side
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2221
diff
changeset
|
364 |
('allow-email-login', |
e1d2df3f1091
move login by email functionnality on the repository side to avoid buggy call to internal_session from the web interface side
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2221
diff
changeset
|
365 |
{'type' : 'yn', |
e1d2df3f1091
move login by email functionnality on the repository side to avoid buggy call to internal_session from the web interface side
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2221
diff
changeset
|
366 |
'default': False, |
e1d2df3f1091
move login by email functionnality on the repository side to avoid buggy call to internal_session from the web interface side
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2221
diff
changeset
|
367 |
'help': 'allow users to login with their primary email if set', |
5323
329b4f6d18b4
[config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5322
diff
changeset
|
368 |
'group': 'main', 'level': 2, |
2267
e1d2df3f1091
move login by email functionnality on the repository side to avoid buggy call to internal_session from the web interface side
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2221
diff
changeset
|
369 |
}), |
0 | 370 |
('mangle-emails', |
371 |
{'type' : 'yn', |
|
372 |
'default': False, |
|
373 |
'help': "don't display actual email addresses but mangle them if \ |
|
374 |
this option is set to yes", |
|
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
375 |
'group': 'email', 'level': 3, |
0 | 376 |
}), |
377 |
) |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
378 |
# static and class methods used to get instance independant resources ## |
0 | 379 |
@staticmethod |
380 |
def cubicweb_version(): |
|
381 |
"""return installed cubicweb version""" |
|
382 |
from logilab.common.changelog import Version |
|
383 |
from cubicweb import __pkginfo__ |
|
384 |
version = __pkginfo__.numversion |
|
385 |
assert len(version) == 3, version |
|
386 |
return Version(version) |
|
1446 | 387 |
|
0 | 388 |
@staticmethod |
389 |
def persistent_options_configuration(): |
|
390 |
return Configuration(options=PERSISTENT_OPTIONS) |
|
391 |
||
392 |
@classmethod |
|
393 |
def shared_dir(cls): |
|
394 |
"""return the shared data directory (i.e. directory where standard |
|
395 |
library views and data may be found) |
|
396 |
""" |
|
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:
3564
diff
changeset
|
397 |
if CWDEV: |
0 | 398 |
return join(CW_SOFTWARE_ROOT, 'web') |
1039 | 399 |
return cls.cube_dir('shared') |
1446 | 400 |
|
0 | 401 |
@classmethod |
402 |
def i18n_lib_dir(cls): |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
403 |
"""return instance's i18n directory""" |
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:
3564
diff
changeset
|
404 |
if CWDEV: |
0 | 405 |
return join(CW_SOFTWARE_ROOT, 'i18n') |
406 |
return join(cls.shared_dir(), 'i18n') |
|
407 |
||
408 |
@classmethod |
|
6749
48f468f33704
[config, i18n] Create default translation mechanism for all supported languages.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6748
diff
changeset
|
409 |
def cw_languages(cls): |
48f468f33704
[config, i18n] Create default translation mechanism for all supported languages.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6748
diff
changeset
|
410 |
for fname in os.listdir(join(cls.i18n_lib_dir())): |
48f468f33704
[config, i18n] Create default translation mechanism for all supported languages.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6748
diff
changeset
|
411 |
if fname.endswith('.po'): |
48f468f33704
[config, i18n] Create default translation mechanism for all supported languages.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6748
diff
changeset
|
412 |
yield splitext(fname)[0] |
48f468f33704
[config, i18n] Create default translation mechanism for all supported languages.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6748
diff
changeset
|
413 |
|
48f468f33704
[config, i18n] Create default translation mechanism for all supported languages.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6748
diff
changeset
|
414 |
|
48f468f33704
[config, i18n] Create default translation mechanism for all supported languages.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6748
diff
changeset
|
415 |
@classmethod |
0 | 416 |
def available_cubes(cls): |
5298
66b0987716f9
[config] fix #799884: do not attempt to load stuff with incorrect names which sit in cubes/
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5274
diff
changeset
|
417 |
import re |
1015
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
418 |
cubes = set() |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
419 |
for directory in cls.cubes_search_path(): |
5086
bd13d9268b44
[cleanup] exists imported, use it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5043
diff
changeset
|
420 |
if not exists(directory): |
4605
7f884ee28519
fix dumb name error triggering crash when some directory in cubes search path doesn't exist
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4491
diff
changeset
|
421 |
cls.error('unexistant directory in cubes search path: %s' |
5298
66b0987716f9
[config] fix #799884: do not attempt to load stuff with incorrect names which sit in cubes/
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5274
diff
changeset
|
422 |
% directory) |
4001
bc31ede2085d
dont crash if directory doesn't exist
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3915
diff
changeset
|
423 |
continue |
1015
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
424 |
for cube in os.listdir(directory): |
5298
66b0987716f9
[config] fix #799884: do not attempt to load stuff with incorrect names which sit in cubes/
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5274
diff
changeset
|
425 |
if cube == 'shared': |
5026
1f8238eaec9b
[config] more cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5025
diff
changeset
|
426 |
continue |
5298
66b0987716f9
[config] fix #799884: do not attempt to load stuff with incorrect names which sit in cubes/
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5274
diff
changeset
|
427 |
if not re.match('[_A-Za-z][_A-Za-z0-9]*$', cube): |
66b0987716f9
[config] fix #799884: do not attempt to load stuff with incorrect names which sit in cubes/
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5274
diff
changeset
|
428 |
continue # skip invalid python package name |
66b0987716f9
[config] fix #799884: do not attempt to load stuff with incorrect names which sit in cubes/
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5274
diff
changeset
|
429 |
cubedir = join(directory, cube) |
66b0987716f9
[config] fix #799884: do not attempt to load stuff with incorrect names which sit in cubes/
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5274
diff
changeset
|
430 |
if isdir(cubedir) and exists(join(cubedir, '__init__.py')): |
1015
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
431 |
cubes.add(cube) |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
432 |
return sorted(cubes) |
1446 | 433 |
|
0 | 434 |
@classmethod |
1015
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
435 |
def cubes_search_path(cls): |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
436 |
"""return the path of directories where cubes should be searched""" |
5049
1b5c873029a1
take care to empty string in cubes search path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5048
diff
changeset
|
437 |
path = [abspath(normpath(directory)) for directory in cls.CUBES_PATH |
1b5c873029a1
take care to empty string in cubes search path
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5048
diff
changeset
|
438 |
if directory.strip() and exists(directory.strip())] |
4606
3b7ce7036b19
dont add CUBES_DIR to cubes search path if it doesn't exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4605
diff
changeset
|
439 |
if not cls.CUBES_DIR in path and exists(cls.CUBES_DIR): |
1015
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
440 |
path.append(cls.CUBES_DIR) |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
441 |
return path |
1446 | 442 |
|
4323
aae19998dd93
move extra path computing as a configuration class property so we can reused it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4322
diff
changeset
|
443 |
@classproperty |
aae19998dd93
move extra path computing as a configuration class property so we can reused it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4322
diff
changeset
|
444 |
def extrapath(cls): |
aae19998dd93
move extra path computing as a configuration class property so we can reused it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4322
diff
changeset
|
445 |
extrapath = {} |
aae19998dd93
move extra path computing as a configuration class property so we can reused it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4322
diff
changeset
|
446 |
for cubesdir in cls.cubes_search_path(): |
aae19998dd93
move extra path computing as a configuration class property so we can reused it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4322
diff
changeset
|
447 |
if cubesdir != cls.CUBES_DIR: |
aae19998dd93
move extra path computing as a configuration class property so we can reused it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4322
diff
changeset
|
448 |
extrapath[cubesdir] = 'cubes' |
4325 | 449 |
return extrapath |
4323
aae19998dd93
move extra path computing as a configuration class property so we can reused it
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4322
diff
changeset
|
450 |
|
0 | 451 |
@classmethod |
452 |
def cube_dir(cls, cube): |
|
6799
30faf6021278
[config] use %r instead of %s for cube name makes things clearer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6788
diff
changeset
|
453 |
"""return the cube directory for the given cube id, raise |
30faf6021278
[config] use %r instead of %s for cube name makes things clearer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6788
diff
changeset
|
454 |
`ConfigurationError` if it doesn't exist |
0 | 455 |
""" |
1015
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
456 |
for directory in cls.cubes_search_path(): |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
457 |
cubedir = join(directory, cube) |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
458 |
if exists(cubedir): |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
459 |
return cubedir |
6799
30faf6021278
[config] use %r instead of %s for cube name makes things clearer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6788
diff
changeset
|
460 |
raise ConfigurationError('no cube %r in %s' % ( |
30faf6021278
[config] use %r instead of %s for cube name makes things clearer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6788
diff
changeset
|
461 |
cube, cls.cubes_search_path())) |
0 | 462 |
|
463 |
@classmethod |
|
464 |
def cube_migration_scripts_dir(cls, cube): |
|
465 |
"""cube migration scripts directory""" |
|
466 |
return join(cls.cube_dir(cube), 'migration') |
|
1446 | 467 |
|
0 | 468 |
@classmethod |
469 |
def cube_pkginfo(cls, cube): |
|
470 |
"""return the information module for the given cube""" |
|
471 |
cube = CW_MIGRATION_MAP.get(cube, cube) |
|
472 |
try: |
|
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
473 |
parent = __import__('cubes.%s.__pkginfo__' % cube) |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
474 |
return getattr(parent, cube).__pkginfo__ |
8695
358d8bed9626
[toward-py3k] rewrite to "except AnException as exc:" (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
8669
diff
changeset
|
475 |
except Exception as ex: |
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
476 |
raise ConfigurationError( |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
477 |
'unable to find packaging information for cube %s (%s: %s)' |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
478 |
% (cube, ex.__class__.__name__, ex)) |
0 | 479 |
|
480 |
@classmethod |
|
481 |
def cube_version(cls, cube): |
|
1446 | 482 |
"""return the version of the cube located in the given directory |
0 | 483 |
""" |
484 |
from logilab.common.changelog import Version |
|
485 |
version = cls.cube_pkginfo(cube).numversion |
|
486 |
assert len(version) == 3, version |
|
487 |
return Version(version) |
|
488 |
||
489 |
@classmethod |
|
5025
2826f5406201
deprecate __use__ and __recommend__
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5023
diff
changeset
|
490 |
def _cube_deps(cls, cube, key, oldkey): |
2826f5406201
deprecate __use__ and __recommend__
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5023
diff
changeset
|
491 |
"""return cubicweb cubes used by the given cube""" |
2826f5406201
deprecate __use__ and __recommend__
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5023
diff
changeset
|
492 |
pkginfo = cls.cube_pkginfo(cube) |
2826f5406201
deprecate __use__ and __recommend__
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5023
diff
changeset
|
493 |
try: |
5163
3079b8345915
[pkginfo] when only __depends__ is specified, deduced __depends_cubes__ from it (same thing for recommends) ; fix ad skel pkginfo on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5159
diff
changeset
|
494 |
# explicit __xxx_cubes__ attribute |
5025
2826f5406201
deprecate __use__ and __recommend__
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5023
diff
changeset
|
495 |
deps = getattr(pkginfo, key) |
2826f5406201
deprecate __use__ and __recommend__
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5023
diff
changeset
|
496 |
except AttributeError: |
5163
3079b8345915
[pkginfo] when only __depends__ is specified, deduced __depends_cubes__ from it (same thing for recommends) ; fix ad skel pkginfo on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5159
diff
changeset
|
497 |
# deduce cubes from generic __xxx__ attribute |
3079b8345915
[pkginfo] when only __depends__ is specified, deduced __depends_cubes__ from it (same thing for recommends) ; fix ad skel pkginfo on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5159
diff
changeset
|
498 |
try: |
3079b8345915
[pkginfo] when only __depends__ is specified, deduced __depends_cubes__ from it (same thing for recommends) ; fix ad skel pkginfo on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5159
diff
changeset
|
499 |
gendeps = getattr(pkginfo, key.replace('_cubes', '')) |
3079b8345915
[pkginfo] when only __depends__ is specified, deduced __depends_cubes__ from it (same thing for recommends) ; fix ad skel pkginfo on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5159
diff
changeset
|
500 |
except AttributeError: |
9255
46f41c3e1443
remove 3.8 bw compat
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9251
diff
changeset
|
501 |
deps = {} |
5025
2826f5406201
deprecate __use__ and __recommend__
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5023
diff
changeset
|
502 |
else: |
5163
3079b8345915
[pkginfo] when only __depends__ is specified, deduced __depends_cubes__ from it (same thing for recommends) ; fix ad skel pkginfo on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5159
diff
changeset
|
503 |
deps = dict( (x[len('cubicweb-'):], v) |
3079b8345915
[pkginfo] when only __depends__ is specified, deduced __depends_cubes__ from it (same thing for recommends) ; fix ad skel pkginfo on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5159
diff
changeset
|
504 |
for x, v in gendeps.iteritems() |
3079b8345915
[pkginfo] when only __depends__ is specified, deduced __depends_cubes__ from it (same thing for recommends) ; fix ad skel pkginfo on the way
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5159
diff
changeset
|
505 |
if x.startswith('cubicweb-')) |
5917
64198285352e
[config] expand_cubes(with_recommends=True) shouldn't return recommened-but-not-installed cubes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
506 |
for depcube in deps: |
64198285352e
[config] expand_cubes(with_recommends=True) shouldn't return recommened-but-not-installed cubes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
507 |
try: |
64198285352e
[config] expand_cubes(with_recommends=True) shouldn't return recommened-but-not-installed cubes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
508 |
newname = CW_MIGRATION_MAP[depcube] |
64198285352e
[config] expand_cubes(with_recommends=True) shouldn't return recommened-but-not-installed cubes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
509 |
except KeyError: |
64198285352e
[config] expand_cubes(with_recommends=True) shouldn't return recommened-but-not-installed cubes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
510 |
pass |
64198285352e
[config] expand_cubes(with_recommends=True) shouldn't return recommened-but-not-installed cubes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
511 |
else: |
64198285352e
[config] expand_cubes(with_recommends=True) shouldn't return recommened-but-not-installed cubes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
512 |
deps[newname] = deps.pop(depcube) |
5025
2826f5406201
deprecate __use__ and __recommend__
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5023
diff
changeset
|
513 |
return deps |
2826f5406201
deprecate __use__ and __recommend__
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5023
diff
changeset
|
514 |
|
2826f5406201
deprecate __use__ and __recommend__
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5023
diff
changeset
|
515 |
@classmethod |
6659
6205927e927a
fix problem introduced with previous commit
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
6657
diff
changeset
|
516 |
def cube_depends_cubicweb_version(cls, cube): |
6205927e927a
fix problem introduced with previous commit
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
6657
diff
changeset
|
517 |
# XXX no backward compat (see _cube_deps above) |
6205927e927a
fix problem introduced with previous commit
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
6657
diff
changeset
|
518 |
try: |
6205927e927a
fix problem introduced with previous commit
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
6657
diff
changeset
|
519 |
pkginfo = cls.cube_pkginfo(cube) |
6205927e927a
fix problem introduced with previous commit
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
6657
diff
changeset
|
520 |
deps = getattr(pkginfo, '__depends__') |
6205927e927a
fix problem introduced with previous commit
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
6657
diff
changeset
|
521 |
return deps.get('cubicweb') |
6205927e927a
fix problem introduced with previous commit
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
6657
diff
changeset
|
522 |
except AttributeError: |
6205927e927a
fix problem introduced with previous commit
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
6657
diff
changeset
|
523 |
return None |
6205927e927a
fix problem introduced with previous commit
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
6657
diff
changeset
|
524 |
|
6205927e927a
fix problem introduced with previous commit
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
6657
diff
changeset
|
525 |
@classmethod |
0 | 526 |
def cube_dependencies(cls, cube): |
527 |
"""return cubicweb cubes used by the given cube""" |
|
5025
2826f5406201
deprecate __use__ and __recommend__
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5023
diff
changeset
|
528 |
return cls._cube_deps(cube, '__depends_cubes__', '__use__') |
0 | 529 |
|
530 |
@classmethod |
|
531 |
def cube_recommends(cls, cube): |
|
532 |
"""return cubicweb cubes recommended by the given cube""" |
|
5025
2826f5406201
deprecate __use__ and __recommend__
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5023
diff
changeset
|
533 |
return cls._cube_deps(cube, '__recommends_cubes__', '__recommend__') |
0 | 534 |
|
535 |
@classmethod |
|
2762
b1bb33b37992
[config] new with_recommends option to expand_cubes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2665
diff
changeset
|
536 |
def expand_cubes(cls, cubes, with_recommends=False): |
0 | 537 |
"""expand the given list of top level cubes used by adding recursivly |
538 |
each cube dependencies |
|
539 |
""" |
|
540 |
cubes = list(cubes) |
|
541 |
todo = cubes[:] |
|
5917
64198285352e
[config] expand_cubes(with_recommends=True) shouldn't return recommened-but-not-installed cubes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
542 |
if with_recommends: |
64198285352e
[config] expand_cubes(with_recommends=True) shouldn't return recommened-but-not-installed cubes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
543 |
available = set(cls.available_cubes()) |
0 | 544 |
while todo: |
545 |
cube = todo.pop(0) |
|
546 |
for depcube in cls.cube_dependencies(cube): |
|
547 |
if depcube not in cubes: |
|
548 |
cubes.append(depcube) |
|
549 |
todo.append(depcube) |
|
2762
b1bb33b37992
[config] new with_recommends option to expand_cubes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2665
diff
changeset
|
550 |
if with_recommends: |
b1bb33b37992
[config] new with_recommends option to expand_cubes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2665
diff
changeset
|
551 |
for depcube in cls.cube_recommends(cube): |
5917
64198285352e
[config] expand_cubes(with_recommends=True) shouldn't return recommened-but-not-installed cubes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5890
diff
changeset
|
552 |
if depcube not in cubes and depcube in available: |
2762
b1bb33b37992
[config] new with_recommends option to expand_cubes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2665
diff
changeset
|
553 |
cubes.append(depcube) |
b1bb33b37992
[config] new with_recommends option to expand_cubes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2665
diff
changeset
|
554 |
todo.append(depcube) |
0 | 555 |
return cubes |
556 |
||
9669
283503f58400
[cwconfig] Remove useless 'ui-cube' configuration option (closes #3728904)
Rémi Cardona <remi.cardona@logilab.fr>
parents:
9363
diff
changeset
|
557 |
@classmethod |
283503f58400
[cwconfig] Remove useless 'ui-cube' configuration option (closes #3728904)
Rémi Cardona <remi.cardona@logilab.fr>
parents:
9363
diff
changeset
|
558 |
def reorder_cubes(cls, cubes): |
0 | 559 |
"""reorder cubes from the top level cubes to inner dependencies |
560 |
cubes |
|
561 |
""" |
|
5322
c0b7687bce3d
[config] graph ordering function moved to lgc 0.50
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5298
diff
changeset
|
562 |
from logilab.common.graph import ordered_nodes, UnorderableGraph |
0 | 563 |
graph = {} |
564 |
for cube in cubes: |
|
565 |
cube = CW_MIGRATION_MAP.get(cube, cube) |
|
9669
283503f58400
[cwconfig] Remove useless 'ui-cube' configuration option (closes #3728904)
Rémi Cardona <remi.cardona@logilab.fr>
parents:
9363
diff
changeset
|
566 |
graph[cube] = set(dep for dep in cls.cube_dependencies(cube) |
5025
2826f5406201
deprecate __use__ and __recommend__
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5023
diff
changeset
|
567 |
if dep in cubes) |
9669
283503f58400
[cwconfig] Remove useless 'ui-cube' configuration option (closes #3728904)
Rémi Cardona <remi.cardona@logilab.fr>
parents:
9363
diff
changeset
|
568 |
graph[cube] |= set(dep for dep in cls.cube_recommends(cube) |
5025
2826f5406201
deprecate __use__ and __recommend__
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5023
diff
changeset
|
569 |
if dep in cubes) |
5322
c0b7687bce3d
[config] graph ordering function moved to lgc 0.50
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5298
diff
changeset
|
570 |
try: |
c0b7687bce3d
[config] graph ordering function moved to lgc 0.50
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5298
diff
changeset
|
571 |
return ordered_nodes(graph) |
8695
358d8bed9626
[toward-py3k] rewrite to "except AnException as exc:" (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
8669
diff
changeset
|
572 |
except UnorderableGraph as ex: |
8733
bdc50659f648
[cwconfig] Fix exception handling when building the cube dependency graph
Rémi Cardona <remi.cardona@logilab.fr>
parents:
8695
diff
changeset
|
573 |
raise ConfigurationError(ex) |
1446 | 574 |
|
0 | 575 |
@classmethod |
576 |
def cls_adjust_sys_path(cls): |
|
577 |
"""update python path if necessary""" |
|
1023
278f997aa257
fix sys.path adjustment
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1015
diff
changeset
|
578 |
cubes_parent_dir = normpath(join(cls.CUBES_DIR, '..')) |
278f997aa257
fix sys.path adjustment
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1015
diff
changeset
|
579 |
if not cubes_parent_dir in sys.path: |
278f997aa257
fix sys.path adjustment
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1015
diff
changeset
|
580 |
sys.path.insert(0, cubes_parent_dir) |
0 | 581 |
try: |
1015
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
582 |
import cubes |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
583 |
cubes.__path__ = cls.cubes_search_path() |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
584 |
except ImportError: |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
585 |
return # cubes dir doesn't exists |
0 | 586 |
|
587 |
@classmethod |
|
7005
f45f42256905
[config] we should load available configuration before search for an instance configuration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6846
diff
changeset
|
588 |
def load_available_configs(cls): |
f45f42256905
[config] we should load available configuration before search for an instance configuration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6846
diff
changeset
|
589 |
from logilab.common.modutils import load_module_from_file |
f45f42256905
[config] we should load available configuration before search for an instance configuration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6846
diff
changeset
|
590 |
for conffile in ('web/webconfig.py', 'etwist/twconfig.py', |
f45f42256905
[config] we should load available configuration before search for an instance configuration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6846
diff
changeset
|
591 |
'server/serverconfig.py',): |
f45f42256905
[config] we should load available configuration before search for an instance configuration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6846
diff
changeset
|
592 |
if exists(join(CW_SOFTWARE_ROOT, conffile)): |
f45f42256905
[config] we should load available configuration before search for an instance configuration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6846
diff
changeset
|
593 |
load_module_from_file(join(CW_SOFTWARE_ROOT, conffile)) |
f45f42256905
[config] we should load available configuration before search for an instance configuration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6846
diff
changeset
|
594 |
|
f45f42256905
[config] we should load available configuration before search for an instance configuration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6846
diff
changeset
|
595 |
@classmethod |
0 | 596 |
def load_cwctl_plugins(cls): |
597 |
from logilab.common.modutils import load_module_from_file |
|
598 |
cls.cls_adjust_sys_path() |
|
599 |
for ctlfile in ('web/webctl.py', 'etwist/twctl.py', |
|
4606
3b7ce7036b19
dont add CUBES_DIR to cubes search path if it doesn't exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4605
diff
changeset
|
600 |
'server/serverctl.py', |
0 | 601 |
'devtools/devctl.py', 'goa/goactl.py'): |
602 |
if exists(join(CW_SOFTWARE_ROOT, ctlfile)): |
|
3269
02a918f108a7
prevent some command providers to stop using cubicweb-ctl (current case : goactl when vobject is not there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3118
diff
changeset
|
603 |
try: |
02a918f108a7
prevent some command providers to stop using cubicweb-ctl (current case : goactl when vobject is not there)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3118
diff
changeset
|
604 |
load_module_from_file(join(CW_SOFTWARE_ROOT, ctlfile)) |
8695
358d8bed9626
[toward-py3k] rewrite to "except AnException as exc:" (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
8669
diff
changeset
|
605 |
except ImportError as err: |
7005
f45f42256905
[config] we should load available configuration before search for an instance configuration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6846
diff
changeset
|
606 |
cls.error('could not import the command provider %s: %s', |
f45f42256905
[config] we should load available configuration before search for an instance configuration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6846
diff
changeset
|
607 |
ctlfile, err) |
0 | 608 |
cls.info('loaded cubicweb-ctl plugin %s', ctlfile) |
609 |
for cube in cls.available_cubes(): |
|
4135
cb0d0bf255f7
look for cubicweb-ctl plugins in the ccplugin.py file, keeping bw compat on ecplugin.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4023
diff
changeset
|
610 |
pluginfile = join(cls.cube_dir(cube), 'ccplugin.py') |
1015
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
611 |
initfile = join(cls.cube_dir(cube), '__init__.py') |
0 | 612 |
if exists(pluginfile): |
613 |
try: |
|
4135
cb0d0bf255f7
look for cubicweb-ctl plugins in the ccplugin.py file, keeping bw compat on ecplugin.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4023
diff
changeset
|
614 |
__import__('cubes.%s.ccplugin' % cube) |
cb0d0bf255f7
look for cubicweb-ctl plugins in the ccplugin.py file, keeping bw compat on ecplugin.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4023
diff
changeset
|
615 |
cls.info('loaded cubicweb-ctl plugin from %s', cube) |
7815
2a164a9cf81c
[exceptions] stop catching any exception in various places (closes #1942716)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7691
diff
changeset
|
616 |
except Exception: |
4135
cb0d0bf255f7
look for cubicweb-ctl plugins in the ccplugin.py file, keeping bw compat on ecplugin.py
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4023
diff
changeset
|
617 |
cls.exception('while loading plugin %s', pluginfile) |
0 | 618 |
elif exists(initfile): |
619 |
try: |
|
620 |
__import__('cubes.%s' % cube) |
|
7815
2a164a9cf81c
[exceptions] stop catching any exception in various places (closes #1942716)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7691
diff
changeset
|
621 |
except Exception: |
0 | 622 |
cls.exception('while loading cube %s', cube) |
623 |
else: |
|
1446 | 624 |
cls.warning('no __init__ file in cube %s', cube) |
0 | 625 |
|
626 |
@classmethod |
|
627 |
def init_available_cubes(cls): |
|
628 |
"""cubes may register some sources (svnfile for instance) in their |
|
629 |
__init__ file, so they should be loaded early in the startup process |
|
630 |
""" |
|
631 |
for cube in cls.available_cubes(): |
|
632 |
try: |
|
633 |
__import__('cubes.%s' % cube) |
|
8695
358d8bed9626
[toward-py3k] rewrite to "except AnException as exc:" (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
8669
diff
changeset
|
634 |
except Exception as ex: |
0 | 635 |
cls.warning("can't init cube %s: %s", cube, ex) |
1446 | 636 |
|
2657
de974465d381
[appobject] kill VObject class, move base selector classes to appobject
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2654
diff
changeset
|
637 |
cubicweb_appobject_path = set(['entities']) |
de974465d381
[appobject] kill VObject class, move base selector classes to appobject
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2654
diff
changeset
|
638 |
cube_appobject_path = set(['entities']) |
0 | 639 |
|
5442
3ed8afbbdf70
[webconfig] refactor/cleanup debug mode management on startup: simply use config.debugmode instead of debug argument everywhere...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
640 |
def __init__(self, debugmode=False): |
7822
ce8a4de2ecf1
[warnings] explicitly ask to show DeprecationWarning in debug mode (closes #1942760)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7815
diff
changeset
|
641 |
if debugmode: |
ce8a4de2ecf1
[warnings] explicitly ask to show DeprecationWarning in debug mode (closes #1942760)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7815
diff
changeset
|
642 |
# in python 2.7, DeprecationWarning are not shown anymore by default |
ce8a4de2ecf1
[warnings] explicitly ask to show DeprecationWarning in debug mode (closes #1942760)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7815
diff
changeset
|
643 |
filterwarnings('default', category=DeprecationWarning) |
4023
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
644 |
register_stored_procedures() |
6494
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
645 |
self._cubes = None |
6748
52226299c352
[config] Use newstyle call to parent classe method.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6741
diff
changeset
|
646 |
super(CubicWebNoAppConfiguration, self).__init__() |
5442
3ed8afbbdf70
[webconfig] refactor/cleanup debug mode management on startup: simply use config.debugmode instead of debug argument everywhere...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
647 |
self.debugmode = debugmode |
0 | 648 |
self.adjust_sys_path() |
649 |
self.load_defaults() |
|
5444
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5442
diff
changeset
|
650 |
# will be properly initialized later by _gettext_init |
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5442
diff
changeset
|
651 |
self.translations = {'en': (unicode, lambda ctx, msgid: unicode(msgid) )} |
5812
d970049d7cfd
[dbapi] Connection.load_appobjects should load site_cubicweb files as well, they may contains necessary RQL extension function definitions. Also kill some broken deprecated code in this method.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5647
diff
changeset
|
652 |
self._site_loaded = set() |
4118
8a9a00a9405c
quick and dirty fix trying to avoid rest directive conflicts when using sphinx (which seems to import the code)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4095
diff
changeset
|
653 |
# don't register ReStructured Text directives by simple import, avoid pb |
8a9a00a9405c
quick and dirty fix trying to avoid rest directive conflicts when using sphinx (which seems to import the code)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4095
diff
changeset
|
654 |
# with eg sphinx. |
8a9a00a9405c
quick and dirty fix trying to avoid rest directive conflicts when using sphinx (which seems to import the code)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4095
diff
changeset
|
655 |
# XXX should be done properly with a function from cw.uicfg |
8a9a00a9405c
quick and dirty fix trying to avoid rest directive conflicts when using sphinx (which seems to import the code)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4095
diff
changeset
|
656 |
try: |
8a9a00a9405c
quick and dirty fix trying to avoid rest directive conflicts when using sphinx (which seems to import the code)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4095
diff
changeset
|
657 |
from cubicweb.ext.rest import cw_rest_init |
8a9a00a9405c
quick and dirty fix trying to avoid rest directive conflicts when using sphinx (which seems to import the code)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4095
diff
changeset
|
658 |
except ImportError: |
8a9a00a9405c
quick and dirty fix trying to avoid rest directive conflicts when using sphinx (which seems to import the code)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4095
diff
changeset
|
659 |
pass |
8a9a00a9405c
quick and dirty fix trying to avoid rest directive conflicts when using sphinx (which seems to import the code)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4095
diff
changeset
|
660 |
else: |
8a9a00a9405c
quick and dirty fix trying to avoid rest directive conflicts when using sphinx (which seems to import the code)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4095
diff
changeset
|
661 |
cw_rest_init() |
0 | 662 |
|
663 |
def adjust_sys_path(self): |
|
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
664 |
# overriden in CubicWebConfiguration |
0 | 665 |
self.cls_adjust_sys_path() |
1446 | 666 |
|
5442
3ed8afbbdf70
[webconfig] refactor/cleanup debug mode management on startup: simply use config.debugmode instead of debug argument everywhere...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
667 |
def init_log(self, logthreshold=None, logfile=None, syslog=False): |
0 | 668 |
"""init the log service""" |
180
8bcebdb5f55d
code moved to logilab.common.logging_ext
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
140
diff
changeset
|
669 |
if logthreshold is None: |
5442
3ed8afbbdf70
[webconfig] refactor/cleanup debug mode management on startup: simply use config.debugmode instead of debug argument everywhere...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
670 |
if self.debugmode: |
180
8bcebdb5f55d
code moved to logilab.common.logging_ext
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
140
diff
changeset
|
671 |
logthreshold = 'DEBUG' |
0 | 672 |
else: |
180
8bcebdb5f55d
code moved to logilab.common.logging_ext
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
140
diff
changeset
|
673 |
logthreshold = self['log-threshold'] |
5640
8a6d14f4fb9d
logging settings
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5456
diff
changeset
|
674 |
if sys.platform == 'win32': |
8a6d14f4fb9d
logging settings
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5456
diff
changeset
|
675 |
# no logrotate on win32, so use logging rotation facilities |
8a6d14f4fb9d
logging settings
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5456
diff
changeset
|
676 |
# for now, hard code weekly rotation every sunday, and 52 weeks kept |
8a6d14f4fb9d
logging settings
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5456
diff
changeset
|
677 |
# idea: make this configurable? |
5655 | 678 |
init_log(self.debugmode, syslog, logthreshold, logfile, self.log_format, |
5646
c9550c1239f0
various brown paper bag fixes
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5640
diff
changeset
|
679 |
rotation_parameters={'when': 'W6', # every sunday |
5640
8a6d14f4fb9d
logging settings
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5456
diff
changeset
|
680 |
'interval': 1, |
5812
d970049d7cfd
[dbapi] Connection.load_appobjects should load site_cubicweb files as well, they may contains necessary RQL extension function definitions. Also kill some broken deprecated code in this method.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5647
diff
changeset
|
681 |
'backupCount': 52}) |
5640
8a6d14f4fb9d
logging settings
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5456
diff
changeset
|
682 |
else: |
5655 | 683 |
init_log(self.debugmode, syslog, logthreshold, logfile, self.log_format) |
0 | 684 |
# configure simpleTal logger |
685 |
logging.getLogger('simpleTAL').setLevel(logging.ERROR) |
|
686 |
||
8537
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
687 |
def appobjects_path(self): |
0 | 688 |
"""return a list of files or directories where the registry will look |
689 |
for application objects. By default return nothing in NoApp config. |
|
690 |
""" |
|
691 |
return [] |
|
1446 | 692 |
|
8537
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
693 |
def build_appobjects_path(self, templpath, evobjpath=None, tvobjpath=None): |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
694 |
"""given a list of directories, return a list of sub files and |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
695 |
directories that should be loaded by the instance objects registry. |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
696 |
|
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
697 |
:param evobjpath: |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
698 |
optional list of sub-directories (or files without the .py ext) of |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
699 |
the cubicweb library that should be tested and added to the output list |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
700 |
if they exists. If not give, default to `cubicweb_appobject_path` class |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
701 |
attribute. |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
702 |
:param tvobjpath: |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
703 |
optional list of sub-directories (or files without the .py ext) of |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
704 |
directories given in `templpath` that should be tested and added to |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
705 |
the output list if they exists. If not give, default to |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
706 |
`cube_appobject_path` class attribute. |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
707 |
""" |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
708 |
vregpath = self.build_appobjects_cubicweb_path(evobjpath) |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
709 |
vregpath += self.build_appobjects_cube_path(templpath, tvobjpath) |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
710 |
return vregpath |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
711 |
|
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
712 |
def build_appobjects_cubicweb_path(self, evobjpath=None): |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
713 |
vregpath = [] |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
714 |
if evobjpath is None: |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
715 |
evobjpath = self.cubicweb_appobject_path |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
716 |
# NOTE: for the order, see http://www.cubicweb.org/ticket/2330799 |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
717 |
# it is clearly a workaround |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
718 |
for subdir in sorted(evobjpath, key=lambda x:x != 'entities'): |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
719 |
path = join(CW_SOFTWARE_ROOT, subdir) |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
720 |
if exists(path): |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
721 |
vregpath.append(path) |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
722 |
return vregpath |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
723 |
|
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
724 |
def build_appobjects_cube_path(self, templpath, tvobjpath=None): |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
725 |
vregpath = [] |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
726 |
if tvobjpath is None: |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
727 |
tvobjpath = self.cube_appobject_path |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
728 |
for directory in templpath: |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
729 |
# NOTE: for the order, see http://www.cubicweb.org/ticket/2330799 |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
730 |
for subdir in sorted(tvobjpath, key=lambda x:x != 'entities'): |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
731 |
path = join(directory, subdir) |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
732 |
if exists(path): |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
733 |
vregpath.append(path) |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
734 |
elif exists(path + '.py'): |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
735 |
vregpath.append(path + '.py') |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
736 |
return vregpath |
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
737 |
|
5812
d970049d7cfd
[dbapi] Connection.load_appobjects should load site_cubicweb files as well, they may contains necessary RQL extension function definitions. Also kill some broken deprecated code in this method.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5647
diff
changeset
|
738 |
apphome = None |
d970049d7cfd
[dbapi] Connection.load_appobjects should load site_cubicweb files as well, they may contains necessary RQL extension function definitions. Also kill some broken deprecated code in this method.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5647
diff
changeset
|
739 |
|
d970049d7cfd
[dbapi] Connection.load_appobjects should load site_cubicweb files as well, they may contains necessary RQL extension function definitions. Also kill some broken deprecated code in this method.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5647
diff
changeset
|
740 |
def load_site_cubicweb(self, paths=None): |
d970049d7cfd
[dbapi] Connection.load_appobjects should load site_cubicweb files as well, they may contains necessary RQL extension function definitions. Also kill some broken deprecated code in this method.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5647
diff
changeset
|
741 |
"""load instance's specific site_cubicweb file""" |
d970049d7cfd
[dbapi] Connection.load_appobjects should load site_cubicweb files as well, they may contains necessary RQL extension function definitions. Also kill some broken deprecated code in this method.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5647
diff
changeset
|
742 |
if paths is None: |
d970049d7cfd
[dbapi] Connection.load_appobjects should load site_cubicweb files as well, they may contains necessary RQL extension function definitions. Also kill some broken deprecated code in this method.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5647
diff
changeset
|
743 |
paths = self.cubes_path() |
d970049d7cfd
[dbapi] Connection.load_appobjects should load site_cubicweb files as well, they may contains necessary RQL extension function definitions. Also kill some broken deprecated code in this method.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5647
diff
changeset
|
744 |
if self.apphome is not None: |
d970049d7cfd
[dbapi] Connection.load_appobjects should load site_cubicweb files as well, they may contains necessary RQL extension function definitions. Also kill some broken deprecated code in this method.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5647
diff
changeset
|
745 |
paths = [self.apphome] + paths |
d970049d7cfd
[dbapi] Connection.load_appobjects should load site_cubicweb files as well, they may contains necessary RQL extension function definitions. Also kill some broken deprecated code in this method.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5647
diff
changeset
|
746 |
for path in reversed(paths): |
d970049d7cfd
[dbapi] Connection.load_appobjects should load site_cubicweb files as well, they may contains necessary RQL extension function definitions. Also kill some broken deprecated code in this method.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5647
diff
changeset
|
747 |
sitefile = join(path, 'site_cubicweb.py') |
d970049d7cfd
[dbapi] Connection.load_appobjects should load site_cubicweb files as well, they may contains necessary RQL extension function definitions. Also kill some broken deprecated code in this method.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5647
diff
changeset
|
748 |
if exists(sitefile) and not sitefile in self._site_loaded: |
d970049d7cfd
[dbapi] Connection.load_appobjects should load site_cubicweb files as well, they may contains necessary RQL extension function definitions. Also kill some broken deprecated code in this method.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5647
diff
changeset
|
749 |
self._load_site_cubicweb(sitefile) |
d970049d7cfd
[dbapi] Connection.load_appobjects should load site_cubicweb files as well, they may contains necessary RQL extension function definitions. Also kill some broken deprecated code in this method.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5647
diff
changeset
|
750 |
self._site_loaded.add(sitefile) |
d970049d7cfd
[dbapi] Connection.load_appobjects should load site_cubicweb files as well, they may contains necessary RQL extension function definitions. Also kill some broken deprecated code in this method.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5647
diff
changeset
|
751 |
|
d970049d7cfd
[dbapi] Connection.load_appobjects should load site_cubicweb files as well, they may contains necessary RQL extension function definitions. Also kill some broken deprecated code in this method.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5647
diff
changeset
|
752 |
def _load_site_cubicweb(self, sitefile): |
d970049d7cfd
[dbapi] Connection.load_appobjects should load site_cubicweb files as well, they may contains necessary RQL extension function definitions. Also kill some broken deprecated code in this method.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5647
diff
changeset
|
753 |
# XXX extrapath argument to load_module_from_file only in lgc > 0.50.2 |
d970049d7cfd
[dbapi] Connection.load_appobjects should load site_cubicweb files as well, they may contains necessary RQL extension function definitions. Also kill some broken deprecated code in this method.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5647
diff
changeset
|
754 |
from logilab.common.modutils import load_module_from_modpath, modpath_from_file |
d970049d7cfd
[dbapi] Connection.load_appobjects should load site_cubicweb files as well, they may contains necessary RQL extension function definitions. Also kill some broken deprecated code in this method.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5647
diff
changeset
|
755 |
module = load_module_from_modpath(modpath_from_file(sitefile, self.extrapath)) |
6087
bdfbd6aa5758
[debug] change severity of 'site_cubicweb loaded' message to debug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5960
diff
changeset
|
756 |
self.debug('%s loaded', sitefile) |
5812
d970049d7cfd
[dbapi] Connection.load_appobjects should load site_cubicweb files as well, they may contains necessary RQL extension function definitions. Also kill some broken deprecated code in this method.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5647
diff
changeset
|
757 |
return module |
d970049d7cfd
[dbapi] Connection.load_appobjects should load site_cubicweb files as well, they may contains necessary RQL extension function definitions. Also kill some broken deprecated code in this method.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5647
diff
changeset
|
758 |
|
7031
a04621040cad
[config refactoring] rename eproperty_definition method to cwproperty_definition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7005
diff
changeset
|
759 |
def cwproperty_definitions(self): |
0 | 760 |
cfg = self.persistent_options_configuration() |
761 |
for section, options in cfg.options_by_section(): |
|
762 |
section = section.lower() |
|
763 |
for optname, optdict, value in options: |
|
764 |
key = '%s.%s' % (section, optname) |
|
765 |
type, vocab = self.map_option(optdict) |
|
766 |
default = cfg.option_default(optname, optdict) |
|
767 |
pdef = {'type': type, 'vocabulary': vocab, 'default': default, |
|
768 |
'help': optdict['help'], |
|
769 |
'sitewide': optdict.get('sitewide', False)} |
|
770 |
yield key, pdef |
|
1446 | 771 |
|
0 | 772 |
def map_option(self, optdict): |
773 |
try: |
|
774 |
vocab = optdict['choices'] |
|
775 |
except KeyError: |
|
776 |
vocab = optdict.get('vocabulary') |
|
777 |
if isinstance(vocab, Method): |
|
778 |
vocab = getattr(self, vocab.method, ()) |
|
779 |
return CFGTYPE2ETYPE_MAP[optdict['type']], vocab |
|
780 |
||
3564
b03cc2416cd5
[config] dumb implementation of default_instance_id on no app config since it's referenced
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3539
diff
changeset
|
781 |
def default_instance_id(self): |
b03cc2416cd5
[config] dumb implementation of default_instance_id on no app config since it's referenced
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3539
diff
changeset
|
782 |
"""return the instance identifier, useful for option which need this |
b03cc2416cd5
[config] dumb implementation of default_instance_id on no app config since it's referenced
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3539
diff
changeset
|
783 |
as default value |
b03cc2416cd5
[config] dumb implementation of default_instance_id on no app config since it's referenced
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3539
diff
changeset
|
784 |
""" |
b03cc2416cd5
[config] dumb implementation of default_instance_id on no app config since it's referenced
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3539
diff
changeset
|
785 |
return None |
1446 | 786 |
|
6494
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
787 |
_cubes = None |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
788 |
|
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
789 |
def init_cubes(self, cubes): |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
790 |
self._cubes = self.reorder_cubes(cubes) |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
791 |
# load cubes'__init__.py file first |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
792 |
for cube in cubes: |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
793 |
__import__('cubes.%s' % cube) |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
794 |
self.load_site_cubicweb() |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
795 |
|
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
796 |
def cubes(self): |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
797 |
"""return the list of cubes used by this instance |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
798 |
|
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
799 |
result is ordered from the top level cubes to inner dependencies |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
800 |
cubes |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
801 |
""" |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
802 |
assert self._cubes is not None, 'cubes not initialized' |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
803 |
return self._cubes |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
804 |
|
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
805 |
def cubes_path(self): |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
806 |
"""return the list of path to cubes used by this instance, from outer |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
807 |
most to inner most cubes |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
808 |
""" |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
809 |
return [self.cube_dir(p) for p in self.cubes()] |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
810 |
|
7879
9aae456abab5
[pylint] fix pylint detected errors and tweak it so that pylint -E will be much less verbose next time (+ update some copyrights on the way)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7822
diff
changeset
|
811 |
# these are overridden by set_log_methods below |
9aae456abab5
[pylint] fix pylint detected errors and tweak it so that pylint -E will be much less verbose next time (+ update some copyrights on the way)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7822
diff
changeset
|
812 |
# only defining here to prevent pylint from complaining |
9aae456abab5
[pylint] fix pylint detected errors and tweak it so that pylint -E will be much less verbose next time (+ update some copyrights on the way)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7822
diff
changeset
|
813 |
@classmethod |
9aae456abab5
[pylint] fix pylint detected errors and tweak it so that pylint -E will be much less verbose next time (+ update some copyrights on the way)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7822
diff
changeset
|
814 |
def debug(cls, msg, *a, **kw): |
9aae456abab5
[pylint] fix pylint detected errors and tweak it so that pylint -E will be much less verbose next time (+ update some copyrights on the way)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7822
diff
changeset
|
815 |
pass |
9aae456abab5
[pylint] fix pylint detected errors and tweak it so that pylint -E will be much less verbose next time (+ update some copyrights on the way)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7822
diff
changeset
|
816 |
info = warning = error = critical = exception = debug |
9aae456abab5
[pylint] fix pylint detected errors and tweak it so that pylint -E will be much less verbose next time (+ update some copyrights on the way)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7822
diff
changeset
|
817 |
|
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
818 |
|
0 | 819 |
class CubicWebConfiguration(CubicWebNoAppConfiguration): |
820 |
"""base class for cubicweb server and web configurations""" |
|
1446 | 821 |
|
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
822 |
if CubicWebNoAppConfiguration.mode == 'user': |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
823 |
_INSTANCES_DIR = expanduser('~/etc/cubicweb.d/') |
6502
1e1de0339a95
[config] Put "Instance" and "Instance data" directory within cubiweb install prefix.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6495
diff
changeset
|
824 |
#mode == system' |
1e1de0339a95
[config] Put "Instance" and "Instance data" directory within cubiweb install prefix.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6495
diff
changeset
|
825 |
elif _USR_INSTALL: |
1e1de0339a95
[config] Put "Instance" and "Instance data" directory within cubiweb install prefix.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6495
diff
changeset
|
826 |
_INSTANCES_DIR = '/etc/cubicweb.d/' |
1e1de0339a95
[config] Put "Instance" and "Instance data" directory within cubiweb install prefix.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6495
diff
changeset
|
827 |
else: |
1e1de0339a95
[config] Put "Instance" and "Instance data" directory within cubiweb install prefix.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6495
diff
changeset
|
828 |
_INSTANCES_DIR = join(_INSTALL_PREFIX, 'etc', 'cubicweb.d') |
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
829 |
|
7129
455b503fb7ff
[config] generalise config.creating, allowing to drop set_language class attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7086
diff
changeset
|
830 |
# set to true during repair (shell, migration) to allow some things which |
455b503fb7ff
[config] generalise config.creating, allowing to drop set_language class attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7086
diff
changeset
|
831 |
# wouldn't be possible otherwise |
2473
490f88fb99b6
new distinguish repairing/creating from regular start.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2449
diff
changeset
|
832 |
repairing = False |
1446 | 833 |
|
7879
9aae456abab5
[pylint] fix pylint detected errors and tweak it so that pylint -E will be much less verbose next time (+ update some copyrights on the way)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7822
diff
changeset
|
834 |
# set by upgrade command |
9aae456abab5
[pylint] fix pylint detected errors and tweak it so that pylint -E will be much less verbose next time (+ update some copyrights on the way)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7822
diff
changeset
|
835 |
verbosity = 0 |
9aae456abab5
[pylint] fix pylint detected errors and tweak it so that pylint -E will be much less verbose next time (+ update some copyrights on the way)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7822
diff
changeset
|
836 |
|
0 | 837 |
options = CubicWebNoAppConfiguration.options + ( |
838 |
('log-file', |
|
839 |
{'type' : 'string', |
|
840 |
'default': Method('default_log_file'), |
|
841 |
'help': 'file where output logs should be written', |
|
5323
329b4f6d18b4
[config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5322
diff
changeset
|
842 |
'group': 'main', 'level': 2, |
0 | 843 |
}), |
844 |
# email configuration |
|
845 |
('smtp-host', |
|
846 |
{'type' : 'string', |
|
847 |
'default': 'mail', |
|
848 |
'help': 'hostname of the SMTP mail server', |
|
5323
329b4f6d18b4
[config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5322
diff
changeset
|
849 |
'group': 'email', 'level': 1, |
0 | 850 |
}), |
851 |
('smtp-port', |
|
852 |
{'type' : 'int', |
|
853 |
'default': 25, |
|
854 |
'help': 'listening port of the SMTP mail server', |
|
5323
329b4f6d18b4
[config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5322
diff
changeset
|
855 |
'group': 'email', 'level': 1, |
0 | 856 |
}), |
857 |
('sender-name', |
|
858 |
{'type' : 'string', |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
859 |
'default': Method('default_instance_id'), |
0 | 860 |
'help': 'name used as HELO name for outgoing emails from the \ |
861 |
repository.', |
|
5323
329b4f6d18b4
[config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5322
diff
changeset
|
862 |
'group': 'email', 'level': 2, |
0 | 863 |
}), |
864 |
('sender-addr', |
|
865 |
{'type' : 'string', |
|
2351
dddee537e4d5
don't use internal address
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2267
diff
changeset
|
866 |
'default': 'cubicweb@mydomain.com', |
0 | 867 |
'help': 'email address used as HELO address for outgoing emails from \ |
868 |
the repository', |
|
5323
329b4f6d18b4
[config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5322
diff
changeset
|
869 |
'group': 'email', 'level': 1, |
0 | 870 |
}), |
871 |
) |
|
872 |
||
873 |
@classmethod |
|
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
874 |
def instances_dir(cls): |
0 | 875 |
"""return the control directory""" |
6495
3187112bc7cc
#1251878: Cubicweb no longer crash for missing instance and data dir at create.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6192
diff
changeset
|
876 |
return abspath(os.environ.get('CW_INSTANCES_DIR', cls._INSTANCES_DIR)) |
1446 | 877 |
|
0 | 878 |
@classmethod |
879 |
def migration_scripts_dir(cls): |
|
880 |
"""cubicweb migration scripts directory""" |
|
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
881 |
if CWDEV: |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
882 |
return join(CW_SOFTWARE_ROOT, 'misc', 'migration') |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
883 |
mdir = join(_INSTALL_PREFIX, 'share', 'cubicweb', 'migration') |
5028 | 884 |
if not exists(mdir): |
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
885 |
raise ConfigurationError('migration path %s doesn\'t exist' % mdir) |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
886 |
return mdir |
0 | 887 |
|
888 |
@classmethod |
|
7129
455b503fb7ff
[config] generalise config.creating, allowing to drop set_language class attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7086
diff
changeset
|
889 |
def config_for(cls, appid, config=None, debugmode=False, creating=False): |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
890 |
"""return a configuration instance for the given instance identifier |
0 | 891 |
""" |
7005
f45f42256905
[config] we should load available configuration before search for an instance configuration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6846
diff
changeset
|
892 |
cls.load_available_configs() |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
893 |
config = config or guess_configuration(cls.instance_home(appid)) |
0 | 894 |
configcls = configuration_cls(config) |
7129
455b503fb7ff
[config] generalise config.creating, allowing to drop set_language class attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7086
diff
changeset
|
895 |
return configcls(appid, debugmode, creating) |
1446 | 896 |
|
0 | 897 |
@classmethod |
898 |
def possible_configurations(cls, appid): |
|
899 |
"""return the name of possible configurations for the given |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
900 |
instance id |
0 | 901 |
""" |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
902 |
home = cls.instance_home(appid) |
0 | 903 |
return possible_configurations(home) |
1446 | 904 |
|
0 | 905 |
@classmethod |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
906 |
def instance_home(cls, appid): |
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
907 |
"""return the home directory of the instance with the given |
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
908 |
instance id |
0 | 909 |
""" |
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
910 |
home = join(cls.instances_dir(), appid) |
0 | 911 |
if not exists(home): |
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
912 |
raise ConfigurationError('no such instance %s (check it exists with' |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
913 |
' "cubicweb-ctl list")' % appid) |
0 | 914 |
return home |
915 |
||
9251
e4d753c8b1c4
remove "twisted" configuration (closes #2919310)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8850
diff
changeset
|
916 |
MODES = ('common', 'repository', 'Any') |
0 | 917 |
MCOMPAT = {'all-in-one': MODES, |
9251
e4d753c8b1c4
remove "twisted" configuration (closes #2919310)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8850
diff
changeset
|
918 |
'repository': ('common', 'repository', 'Any')} |
0 | 919 |
@classmethod |
920 |
def accept_mode(cls, mode): |
|
921 |
#assert mode in cls.MODES, mode |
|
922 |
return mode in cls.MCOMPAT[cls.name] |
|
1446 | 923 |
|
0 | 924 |
# default configuration methods ########################################### |
1446 | 925 |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
926 |
def default_instance_id(self): |
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
927 |
"""return the instance identifier, useful for option which need this |
0 | 928 |
as default value |
929 |
""" |
|
930 |
return self.appid |
|
931 |
||
932 |
def default_log_file(self): |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
933 |
"""return default path to the log file of the instance'server""" |
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:
3564
diff
changeset
|
934 |
if self.mode == 'user': |
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
935 |
import tempfile |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
936 |
basepath = join(tempfile.gettempdir(), '%s-%s' % ( |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
937 |
basename(self.appid), self.name)) |
0 | 938 |
path = basepath + '.log' |
939 |
i = 1 |
|
940 |
while exists(path) and i < 100: # arbitrary limit to avoid infinite loop |
|
941 |
try: |
|
942 |
file(path, 'a') |
|
943 |
break |
|
944 |
except IOError: |
|
945 |
path = '%s-%s.log' % (basepath, i) |
|
946 |
i += 1 |
|
947 |
return path |
|
6502
1e1de0339a95
[config] Put "Instance" and "Instance data" directory within cubiweb install prefix.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6495
diff
changeset
|
948 |
if _USR_INSTALL: |
1e1de0339a95
[config] Put "Instance" and "Instance data" directory within cubiweb install prefix.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6495
diff
changeset
|
949 |
return '/var/log/cubicweb/%s-%s.log' % (self.appid, self.name) |
1e1de0339a95
[config] Put "Instance" and "Instance data" directory within cubiweb install prefix.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6495
diff
changeset
|
950 |
else: |
1e1de0339a95
[config] Put "Instance" and "Instance data" directory within cubiweb install prefix.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6495
diff
changeset
|
951 |
log_path = os.path.join(_INSTALL_PREFIX, 'var', 'log', 'cubicweb', '%s-%s.log') |
1e1de0339a95
[config] Put "Instance" and "Instance data" directory within cubiweb install prefix.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6495
diff
changeset
|
952 |
return log_path % (self.appid, self.name) |
1e1de0339a95
[config] Put "Instance" and "Instance data" directory within cubiweb install prefix.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6495
diff
changeset
|
953 |
|
0 | 954 |
def default_pid_file(self): |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
955 |
"""return default path to the pid file of the instance'server""" |
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
956 |
if self.mode == 'system': |
6502
1e1de0339a95
[config] Put "Instance" and "Instance data" directory within cubiweb install prefix.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6495
diff
changeset
|
957 |
if _USR_INSTALL: |
1e1de0339a95
[config] Put "Instance" and "Instance data" directory within cubiweb install prefix.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6495
diff
changeset
|
958 |
default = '/var/run/cubicweb/' |
1e1de0339a95
[config] Put "Instance" and "Instance data" directory within cubiweb install prefix.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6495
diff
changeset
|
959 |
else: |
1e1de0339a95
[config] Put "Instance" and "Instance data" directory within cubiweb install prefix.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6495
diff
changeset
|
960 |
default = os.path.join(_INSTALL_PREFIX, 'var', 'run', 'cubicweb') |
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
961 |
else: |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
962 |
import tempfile |
5960
ffa38c4ec592
[config] run time directory created when necessary on startup, don't check it exists while creating the instance (closes #1177687)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5933
diff
changeset
|
963 |
default = tempfile.gettempdir() |
ffa38c4ec592
[config] run time directory created when necessary on startup, don't check it exists while creating the instance (closes #1177687)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5933
diff
changeset
|
964 |
# runtime directory created on startup if necessary, don't check it |
ffa38c4ec592
[config] run time directory created when necessary on startup, don't check it exists while creating the instance (closes #1177687)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5933
diff
changeset
|
965 |
# exists |
6495
3187112bc7cc
#1251878: Cubicweb no longer crash for missing instance and data dir at create.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6192
diff
changeset
|
966 |
rtdir = abspath(os.environ.get('CW_RUNTIME_DIR', default)) |
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
967 |
return join(rtdir, '%s-%s.pid' % (self.appid, self.name)) |
1446 | 968 |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
969 |
# instance methods used to get instance specific resources ############# |
1446 | 970 |
|
7129
455b503fb7ff
[config] generalise config.creating, allowing to drop set_language class attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7086
diff
changeset
|
971 |
def __init__(self, appid, debugmode=False, creating=False): |
0 | 972 |
self.appid = appid |
7129
455b503fb7ff
[config] generalise config.creating, allowing to drop set_language class attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7086
diff
changeset
|
973 |
# set to true while creating an instance |
455b503fb7ff
[config] generalise config.creating, allowing to drop set_language class attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7086
diff
changeset
|
974 |
self.creating = creating |
6748
52226299c352
[config] Use newstyle call to parent classe method.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6741
diff
changeset
|
975 |
super(CubicWebConfiguration, self).__init__(debugmode) |
6749
48f468f33704
[config, i18n] Create default translation mechanism for all supported languages.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6748
diff
changeset
|
976 |
fake_gettext = (unicode, lambda ctx, msgid: unicode(msgid)) |
48f468f33704
[config, i18n] Create default translation mechanism for all supported languages.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6748
diff
changeset
|
977 |
for lang in self.available_languages(): |
48f468f33704
[config, i18n] Create default translation mechanism for all supported languages.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6748
diff
changeset
|
978 |
self.translations[lang] = fake_gettext |
0 | 979 |
self._cubes = None |
980 |
self.load_file_configuration(self.main_config_file()) |
|
981 |
||
982 |
def adjust_sys_path(self): |
|
6748
52226299c352
[config] Use newstyle call to parent classe method.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6741
diff
changeset
|
983 |
super(CubicWebConfiguration, self).adjust_sys_path() |
0 | 984 |
# adding apphome to python path is not usually necessary in production |
985 |
# environments, but necessary for tests |
|
9682
fcb672023553
[cwconfig] use "foo not in bar" instead of "not foo in bar"
Julien Cristau <julien.cristau@logilab.fr>
parents:
9669
diff
changeset
|
986 |
if self.apphome and self.apphome not in sys.path: |
0 | 987 |
sys.path.insert(0, self.apphome) |
988 |
||
989 |
@property |
|
990 |
def apphome(self): |
|
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
991 |
return join(self.instances_dir(), self.appid) |
1446 | 992 |
|
0 | 993 |
@property |
994 |
def appdatahome(self): |
|
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
995 |
if self.mode == 'system': |
6502
1e1de0339a95
[config] Put "Instance" and "Instance data" directory within cubiweb install prefix.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6495
diff
changeset
|
996 |
if _USR_INSTALL: |
1e1de0339a95
[config] Put "Instance" and "Instance data" directory within cubiweb install prefix.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6495
diff
changeset
|
997 |
iddir = os.path.join('/var','lib', 'cubicweb', 'instances') |
1e1de0339a95
[config] Put "Instance" and "Instance data" directory within cubiweb install prefix.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6495
diff
changeset
|
998 |
else: |
1e1de0339a95
[config] Put "Instance" and "Instance data" directory within cubiweb install prefix.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6495
diff
changeset
|
999 |
iddir = os.path.join(_INSTALL_PREFIX, 'var', 'lib', 'cubicweb', 'instances') |
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
1000 |
else: |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
1001 |
iddir = self.instances_dir() |
6495
3187112bc7cc
#1251878: Cubicweb no longer crash for missing instance and data dir at create.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6192
diff
changeset
|
1002 |
iddir = abspath(os.environ.get('CW_INSTANCES_DATA_DIR', iddir)) |
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
1003 |
return join(iddir, self.appid) |
1446 | 1004 |
|
0 | 1005 |
def init_cubes(self, cubes): |
6494
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
1006 |
super(CubicWebConfiguration, self).init_cubes(cubes) |
0 | 1007 |
# reload config file in cases options are defined in cubes __init__ |
1008 |
# or site_cubicweb files |
|
1009 |
self.load_file_configuration(self.main_config_file()) |
|
1010 |
# configuration initialization hook |
|
1011 |
self.load_configuration() |
|
1446 | 1012 |
|
0 | 1013 |
def add_cubes(self, cubes): |
1014 |
"""add given cubes to the list of used cubes""" |
|
1015 |
if not isinstance(cubes, list): |
|
1016 |
cubes = list(cubes) |
|
1017 |
self._cubes = self.reorder_cubes(list(self._cubes) + cubes) |
|
1446 | 1018 |
|
0 | 1019 |
def main_config_file(self): |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
1020 |
"""return instance's control configuration file""" |
0 | 1021 |
return join(self.apphome, '%s.conf' % self.name) |
1446 | 1022 |
|
0 | 1023 |
def save(self): |
1024 |
"""write down current configuration""" |
|
1025 |
self.generate_config(open(self.main_config_file(), 'w')) |
|
1026 |
||
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:
5917
diff
changeset
|
1027 |
def check_writeable_uid_directory(self, path): |
3d707b8f8a4d
[web configuration] ensure data home directory / uicache file belong to daemon user and are writeable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5917
diff
changeset
|
1028 |
"""check given directory path exists, belongs to the user running the |
3d707b8f8a4d
[web configuration] ensure data home directory / uicache file belong to daemon user and are writeable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5917
diff
changeset
|
1029 |
server process and is writeable. |
3d707b8f8a4d
[web configuration] ensure data home directory / uicache file belong to daemon user and are writeable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5917
diff
changeset
|
1030 |
|
6135
e4b37742f75a
[win32] no os.getuid on windows
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
6087
diff
changeset
|
1031 |
If not, try to fix this, letting exception propagate when not possible. |
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:
5917
diff
changeset
|
1032 |
""" |
3d707b8f8a4d
[web configuration] ensure data home directory / uicache file belong to daemon user and are writeable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5917
diff
changeset
|
1033 |
if not exists(path): |
8484
4c1efb5bde0a
[config] load_configuration should not crash because of fs errors. Closes #2286215
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8477
diff
changeset
|
1034 |
self.info('creating %s directory', path) |
4c1efb5bde0a
[config] load_configuration should not crash because of fs errors. Closes #2286215
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8477
diff
changeset
|
1035 |
try: |
4c1efb5bde0a
[config] load_configuration should not crash because of fs errors. Closes #2286215
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8477
diff
changeset
|
1036 |
os.makedirs(path) |
8695
358d8bed9626
[toward-py3k] rewrite to "except AnException as exc:" (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
8669
diff
changeset
|
1037 |
except OSError as ex: |
8484
4c1efb5bde0a
[config] load_configuration should not crash because of fs errors. Closes #2286215
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8477
diff
changeset
|
1038 |
self.warning('error while creating %s directory: %s', path, ex) |
4c1efb5bde0a
[config] load_configuration should not crash because of fs errors. Closes #2286215
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8477
diff
changeset
|
1039 |
return |
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:
5917
diff
changeset
|
1040 |
if self['uid']: |
3d707b8f8a4d
[web configuration] ensure data home directory / uicache file belong to daemon user and are writeable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5917
diff
changeset
|
1041 |
try: |
3d707b8f8a4d
[web configuration] ensure data home directory / uicache file belong to daemon user and are writeable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5917
diff
changeset
|
1042 |
uid = int(self['uid']) |
3d707b8f8a4d
[web configuration] ensure data home directory / uicache file belong to daemon user and are writeable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5917
diff
changeset
|
1043 |
except ValueError: |
3d707b8f8a4d
[web configuration] ensure data home directory / uicache file belong to daemon user and are writeable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5917
diff
changeset
|
1044 |
from pwd import getpwnam |
3d707b8f8a4d
[web configuration] ensure data home directory / uicache file belong to daemon user and are writeable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5917
diff
changeset
|
1045 |
uid = getpwnam(self['uid']).pw_uid |
3d707b8f8a4d
[web configuration] ensure data home directory / uicache file belong to daemon user and are writeable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5917
diff
changeset
|
1046 |
else: |
6135
e4b37742f75a
[win32] no os.getuid on windows
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
6087
diff
changeset
|
1047 |
try: |
e4b37742f75a
[win32] no os.getuid on windows
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
6087
diff
changeset
|
1048 |
uid = os.getuid() |
e4b37742f75a
[win32] no os.getuid on windows
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
6087
diff
changeset
|
1049 |
except AttributeError: # we are on windows |
e4b37742f75a
[win32] no os.getuid on windows
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
6087
diff
changeset
|
1050 |
return |
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:
5917
diff
changeset
|
1051 |
fstat = os.stat(path) |
3d707b8f8a4d
[web configuration] ensure data home directory / uicache file belong to daemon user and are writeable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5917
diff
changeset
|
1052 |
if fstat.st_uid != uid: |
8484
4c1efb5bde0a
[config] load_configuration should not crash because of fs errors. Closes #2286215
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8477
diff
changeset
|
1053 |
self.info('giving ownership of %s directory to %s', path, self['uid']) |
4c1efb5bde0a
[config] load_configuration should not crash because of fs errors. Closes #2286215
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8477
diff
changeset
|
1054 |
try: |
4c1efb5bde0a
[config] load_configuration should not crash because of fs errors. Closes #2286215
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8477
diff
changeset
|
1055 |
os.chown(path, uid, os.getgid()) |
8695
358d8bed9626
[toward-py3k] rewrite to "except AnException as exc:" (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
8669
diff
changeset
|
1056 |
except OSError as ex: |
8484
4c1efb5bde0a
[config] load_configuration should not crash because of fs errors. Closes #2286215
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8477
diff
changeset
|
1057 |
self.warning('error while giving ownership of %s directory to %s: %s', |
4c1efb5bde0a
[config] load_configuration should not crash because of fs errors. Closes #2286215
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8477
diff
changeset
|
1058 |
path, self['uid'], ex) |
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:
5917
diff
changeset
|
1059 |
if not (fstat.st_mode & stat.S_IWUSR): |
8484
4c1efb5bde0a
[config] load_configuration should not crash because of fs errors. Closes #2286215
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8477
diff
changeset
|
1060 |
self.info('forcing write permission on directory %s', path) |
4c1efb5bde0a
[config] load_configuration should not crash because of fs errors. Closes #2286215
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8477
diff
changeset
|
1061 |
try: |
4c1efb5bde0a
[config] load_configuration should not crash because of fs errors. Closes #2286215
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8477
diff
changeset
|
1062 |
os.chmod(path, fstat.st_mode | stat.S_IWUSR) |
8695
358d8bed9626
[toward-py3k] rewrite to "except AnException as exc:" (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
8669
diff
changeset
|
1063 |
except OSError as ex: |
8484
4c1efb5bde0a
[config] load_configuration should not crash because of fs errors. Closes #2286215
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8477
diff
changeset
|
1064 |
self.warning('error while forcing write permission on directory %s: %s', |
4c1efb5bde0a
[config] load_configuration should not crash because of fs errors. Closes #2286215
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8477
diff
changeset
|
1065 |
path, ex) |
4c1efb5bde0a
[config] load_configuration should not crash because of fs errors. Closes #2286215
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8477
diff
changeset
|
1066 |
return |
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:
5917
diff
changeset
|
1067 |
|
0 | 1068 |
@cached |
1069 |
def instance_md5_version(self): |
|
7879
9aae456abab5
[pylint] fix pylint detected errors and tweak it so that pylint -E will be much less verbose next time (+ update some copyrights on the way)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7822
diff
changeset
|
1070 |
from hashlib import md5 # pylint: disable=E0611 |
0 | 1071 |
infos = [] |
7264
9ed9e1d77ef3
[web config] fix md5 version to ensure cubes order and to include cubicweb version
Florent Cayré
parents:
7179
diff
changeset
|
1072 |
for pkg in sorted(self.cubes()): |
0 | 1073 |
version = self.cube_version(pkg) |
1074 |
infos.append('%s-%s' % (pkg, version)) |
|
7264
9ed9e1d77ef3
[web config] fix md5 version to ensure cubes order and to include cubicweb version
Florent Cayré
parents:
7179
diff
changeset
|
1075 |
infos.append('cubicweb-%s' % str(self.cubicweb_version())) |
7879
9aae456abab5
[pylint] fix pylint detected errors and tweak it so that pylint -E will be much less verbose next time (+ update some copyrights on the way)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7822
diff
changeset
|
1076 |
return md5(';'.join(infos)).hexdigest() |
1446 | 1077 |
|
0 | 1078 |
def load_configuration(self): |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
1079 |
"""load instance's configuration files""" |
0 | 1080 |
super(CubicWebConfiguration, self).load_configuration() |
7129
455b503fb7ff
[config] generalise config.creating, allowing to drop set_language class attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7086
diff
changeset
|
1081 |
if self.apphome and not self.creating: |
0 | 1082 |
# init gettext |
5444
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5442
diff
changeset
|
1083 |
self._gettext_init() |
1446 | 1084 |
|
5812
d970049d7cfd
[dbapi] Connection.load_appobjects should load site_cubicweb files as well, they may contains necessary RQL extension function definitions. Also kill some broken deprecated code in this method.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5647
diff
changeset
|
1085 |
def _load_site_cubicweb(self, sitefile): |
d970049d7cfd
[dbapi] Connection.load_appobjects should load site_cubicweb files as well, they may contains necessary RQL extension function definitions. Also kill some broken deprecated code in this method.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5647
diff
changeset
|
1086 |
# overriden to register cube specific options |
d970049d7cfd
[dbapi] Connection.load_appobjects should load site_cubicweb files as well, they may contains necessary RQL extension function definitions. Also kill some broken deprecated code in this method.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5647
diff
changeset
|
1087 |
mod = super(CubicWebConfiguration, self)._load_site_cubicweb(sitefile) |
d970049d7cfd
[dbapi] Connection.load_appobjects should load site_cubicweb files as well, they may contains necessary RQL extension function definitions. Also kill some broken deprecated code in this method.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5647
diff
changeset
|
1088 |
if getattr(mod, 'options', None): |
5817
e4207221f3f5
[config] fix dumb name error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5812
diff
changeset
|
1089 |
self.register_options(mod.options) |
5812
d970049d7cfd
[dbapi] Connection.load_appobjects should load site_cubicweb files as well, they may contains necessary RQL extension function definitions. Also kill some broken deprecated code in this method.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5647
diff
changeset
|
1090 |
self.load_defaults() |
d970049d7cfd
[dbapi] Connection.load_appobjects should load site_cubicweb files as well, they may contains necessary RQL extension function definitions. Also kill some broken deprecated code in this method.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5647
diff
changeset
|
1091 |
|
5442
3ed8afbbdf70
[webconfig] refactor/cleanup debug mode management on startup: simply use config.debugmode instead of debug argument everywhere...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
1092 |
def init_log(self, logthreshold=None, force=False): |
0 | 1093 |
"""init the log service""" |
1094 |
if not force and hasattr(self, '_logging_initialized'): |
|
1095 |
return |
|
1096 |
self._logging_initialized = True |
|
6748
52226299c352
[config] Use newstyle call to parent classe method.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6741
diff
changeset
|
1097 |
super_self = super(CubicWebConfiguration, self) |
52226299c352
[config] Use newstyle call to parent classe method.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6741
diff
changeset
|
1098 |
super_self.init_log(logthreshold, logfile=self.get('log-file')) |
0 | 1099 |
# read a config file if it exists |
1100 |
logconfig = join(self.apphome, 'logging.conf') |
|
1101 |
if exists(logconfig): |
|
7178
a62f24e1497e
fileConfig is in logging.config
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7086
diff
changeset
|
1102 |
logging.config.fileConfig(logconfig) |
0 | 1103 |
|
1104 |
def available_languages(self, *args): |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
1105 |
"""return available translation for an instance, by looking for |
0 | 1106 |
compiled catalog |
1107 |
||
4936
a4b772a0d801
Fixed some of the documentation warnings when building the book with sphinx.
Adrien Chauve <adrien.chauve@logilab.fr>
parents:
4889
diff
changeset
|
1108 |
take \*args to be usable as a vocabulary method |
0 | 1109 |
""" |
1110 |
from glob import glob |
|
1111 |
yield 'en' # ensure 'en' is yielded even if no .mo found |
|
1112 |
for path in glob(join(self.apphome, 'i18n', |
|
3118 | 1113 |
'*', 'LC_MESSAGES')): |
1114 |
lang = path.split(os.sep)[-2] |
|
0 | 1115 |
if lang != 'en': |
1116 |
yield lang |
|
1446 | 1117 |
|
5444
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5442
diff
changeset
|
1118 |
def _gettext_init(self): |
0 | 1119 |
"""set language for gettext""" |
8106
241123f7bcd0
[cwconfig] absolute import (closes #2091068)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8031
diff
changeset
|
1120 |
from cubicweb.gettext import translation |
0 | 1121 |
path = join(self.apphome, 'i18n') |
1122 |
for language in self.available_languages(): |
|
1123 |
self.info("loading language %s", language) |
|
1124 |
try: |
|
1125 |
tr = translation('cubicweb', path, languages=[language]) |
|
3275
5247789df541
[gettext] provide GNU contexts to avoid translations ambiguities
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3270
diff
changeset
|
1126 |
self.translations[language] = (tr.ugettext, tr.upgettext) |
0 | 1127 |
except (ImportError, AttributeError, IOError): |
8436
150191e45ee5
[cwconfig] shutup on absent i18n/ mo files when in operating in tests
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8378
diff
changeset
|
1128 |
if self.mode != 'test': |
150191e45ee5
[cwconfig] shutup on absent i18n/ mo files when in operating in tests
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8378
diff
changeset
|
1129 |
# in test contexts, data/i18n does not exist, hence |
150191e45ee5
[cwconfig] shutup on absent i18n/ mo files when in operating in tests
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8378
diff
changeset
|
1130 |
# logging will only pollute the logs |
150191e45ee5
[cwconfig] shutup on absent i18n/ mo files when in operating in tests
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8378
diff
changeset
|
1131 |
self.exception('localisation support error for language %s', |
150191e45ee5
[cwconfig] shutup on absent i18n/ mo files when in operating in tests
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8378
diff
changeset
|
1132 |
language) |
1446 | 1133 |
|
8537
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
1134 |
def appobjects_path(self): |
0 | 1135 |
"""return a list of files or directories where the registry will look |
1136 |
for application objects |
|
1137 |
""" |
|
1138 |
templpath = list(reversed(self.cubes_path())) |
|
1139 |
if self.apphome: # may be unset in tests |
|
1140 |
templpath.append(self.apphome) |
|
8537
e30d0a7f0087
[config] turn internal configuration methods building appobjects search path into normal method rather than class method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8484
diff
changeset
|
1141 |
return self.build_appobjects_path(templpath) |
0 | 1142 |
|
1143 |
def set_sources_mode(self, sources): |
|
1144 |
if not 'all' in sources: |
|
1145 |
print 'warning: ignoring specified sources, requires a repository '\ |
|
1146 |
'configuration' |
|
1446 | 1147 |
|
0 | 1148 |
def migration_handler(self): |
1149 |
"""return a migration handler instance""" |
|
4021
280c910c8710
move i18n / migration modules from cw.common to cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4001
diff
changeset
|
1150 |
from cubicweb.migration import MigrationHelper |
0 | 1151 |
return MigrationHelper(self, verbosity=self.verbosity) |
1152 |
||
1153 |
def i18ncompile(self, langs=None): |
|
4021
280c910c8710
move i18n / migration modules from cw.common to cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4001
diff
changeset
|
1154 |
from cubicweb import i18n |
0 | 1155 |
if langs is None: |
1156 |
langs = self.available_languages() |
|
1157 |
i18ndir = join(self.apphome, 'i18n') |
|
1158 |
if not exists(i18ndir): |
|
1159 |
create_dir(i18ndir) |
|
1160 |
sourcedirs = [join(path, 'i18n') for path in self.cubes_path()] |
|
1161 |
sourcedirs.append(self.i18n_lib_dir()) |
|
1162 |
return i18n.compile_i18n_catalogs(sourcedirs, i18ndir, langs) |
|
1163 |
||
9363
d773589b6d46
[mail] allow to specify SMTP's MAIL FROM address to config.sendmails(). Closes #3373620
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9258
diff
changeset
|
1164 |
def sendmails(self, msgs, fromaddr=None): |
5198
cf8292f80384
[controller] refactor send mail controller to use cwconfig.sendmails
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5143
diff
changeset
|
1165 |
"""msgs: list of 2-uple (message object, recipients). Return False |
cf8292f80384
[controller] refactor send mail controller to use cwconfig.sendmails
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5143
diff
changeset
|
1166 |
if connection to the smtp server failed, else True. |
cf8292f80384
[controller] refactor send mail controller to use cwconfig.sendmails
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5143
diff
changeset
|
1167 |
""" |
2221
d9b85a7b0bdd
create sendmails method on cwconfig, use it in SendMailOp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2220
diff
changeset
|
1168 |
server, port = self['smtp-host'], self['smtp-port'] |
9363
d773589b6d46
[mail] allow to specify SMTP's MAIL FROM address to config.sendmails(). Closes #3373620
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9258
diff
changeset
|
1169 |
if fromaddr is None: |
d773589b6d46
[mail] allow to specify SMTP's MAIL FROM address to config.sendmails(). Closes #3373620
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9258
diff
changeset
|
1170 |
fromaddr = '%s <%s>' % (self['sender-name'], self['sender-addr']) |
2221
d9b85a7b0bdd
create sendmails method on cwconfig, use it in SendMailOp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2220
diff
changeset
|
1171 |
SMTP_LOCK.acquire() |
d9b85a7b0bdd
create sendmails method on cwconfig, use it in SendMailOp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2220
diff
changeset
|
1172 |
try: |
d9b85a7b0bdd
create sendmails method on cwconfig, use it in SendMailOp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2220
diff
changeset
|
1173 |
try: |
d9b85a7b0bdd
create sendmails method on cwconfig, use it in SendMailOp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2220
diff
changeset
|
1174 |
smtp = SMTP(server, port) |
8695
358d8bed9626
[toward-py3k] rewrite to "except AnException as exc:" (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
8669
diff
changeset
|
1175 |
except Exception as ex: |
2221
d9b85a7b0bdd
create sendmails method on cwconfig, use it in SendMailOp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2220
diff
changeset
|
1176 |
self.exception("can't connect to smtp server %s:%s (%s)", |
d9b85a7b0bdd
create sendmails method on cwconfig, use it in SendMailOp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2220
diff
changeset
|
1177 |
server, port, ex) |
5198
cf8292f80384
[controller] refactor send mail controller to use cwconfig.sendmails
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5143
diff
changeset
|
1178 |
return False |
2221
d9b85a7b0bdd
create sendmails method on cwconfig, use it in SendMailOp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2220
diff
changeset
|
1179 |
for msg, recipients in msgs: |
d9b85a7b0bdd
create sendmails method on cwconfig, use it in SendMailOp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2220
diff
changeset
|
1180 |
try: |
9363
d773589b6d46
[mail] allow to specify SMTP's MAIL FROM address to config.sendmails(). Closes #3373620
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9258
diff
changeset
|
1181 |
smtp.sendmail(fromaddr, recipients, msg.as_string()) |
8695
358d8bed9626
[toward-py3k] rewrite to "except AnException as exc:" (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
8669
diff
changeset
|
1182 |
except Exception as ex: |
2221
d9b85a7b0bdd
create sendmails method on cwconfig, use it in SendMailOp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2220
diff
changeset
|
1183 |
self.exception("error sending mail to %s (%s)", |
d9b85a7b0bdd
create sendmails method on cwconfig, use it in SendMailOp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2220
diff
changeset
|
1184 |
recipients, ex) |
d9b85a7b0bdd
create sendmails method on cwconfig, use it in SendMailOp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2220
diff
changeset
|
1185 |
smtp.close() |
d9b85a7b0bdd
create sendmails method on cwconfig, use it in SendMailOp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2220
diff
changeset
|
1186 |
finally: |
d9b85a7b0bdd
create sendmails method on cwconfig, use it in SendMailOp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2220
diff
changeset
|
1187 |
SMTP_LOCK.release() |
5198
cf8292f80384
[controller] refactor send mail controller to use cwconfig.sendmails
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5143
diff
changeset
|
1188 |
return True |
2221
d9b85a7b0bdd
create sendmails method on cwconfig, use it in SendMailOp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2220
diff
changeset
|
1189 |
|
5812
d970049d7cfd
[dbapi] Connection.load_appobjects should load site_cubicweb files as well, they may contains necessary RQL extension function definitions. Also kill some broken deprecated code in this method.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5647
diff
changeset
|
1190 |
set_log_methods(CubicWebNoAppConfiguration, |
d970049d7cfd
[dbapi] Connection.load_appobjects should load site_cubicweb files as well, they may contains necessary RQL extension function definitions. Also kill some broken deprecated code in this method.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5647
diff
changeset
|
1191 |
logging.getLogger('cubicweb.configuration')) |
1446 | 1192 |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
1193 |
# alias to get a configuration instance from an instance id |
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
1194 |
instance_configuration = CubicWebConfiguration.config_for |
2613
5e19c2bb370e
R [all] logilab.common 0.44 provides only deprecated
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2476
diff
changeset
|
1195 |
application_configuration = deprecated('use instance_configuration')(instance_configuration) |
4023
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1196 |
|
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1197 |
|
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1198 |
_EXT_REGISTERED = False |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1199 |
def register_stored_procedures(): |
4848
41f84eea63c9
rename logilab.db into logilab.database
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4831
diff
changeset
|
1200 |
from logilab.database import FunctionDescr |
4023
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1201 |
from rql.utils import register_function, iter_funcnode_variables |
5768
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
1202 |
from rql.nodes import SortTerm, Constant, VariableRef |
4023
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1203 |
|
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1204 |
global _EXT_REGISTERED |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1205 |
if _EXT_REGISTERED: |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1206 |
return |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1207 |
_EXT_REGISTERED = True |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1208 |
|
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1209 |
class COMMA_JOIN(FunctionDescr): |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1210 |
supported_backends = ('postgres', 'sqlite',) |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1211 |
rtype = 'String' |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1212 |
|
4831
c5aec27c1bf7
[repo] use logilab.db instead of lgc.adbh/lgc.db/lgc.sqlgen/indexer, test new date extranction functions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4624
diff
changeset
|
1213 |
def st_description(self, funcnode, mainindex, tr): |
4023
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1214 |
return ', '.join(sorted(term.get_description(mainindex, tr) |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1215 |
for term in iter_funcnode_variables(funcnode))) |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1216 |
|
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1217 |
register_function(COMMA_JOIN) # XXX do not expose? |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1218 |
|
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1219 |
|
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1220 |
class CONCAT_STRINGS(COMMA_JOIN): |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1221 |
aggregat = True |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1222 |
|
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1223 |
register_function(CONCAT_STRINGS) # XXX bw compat |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1224 |
|
4831
c5aec27c1bf7
[repo] use logilab.db instead of lgc.adbh/lgc.db/lgc.sqlgen/indexer, test new date extranction functions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4624
diff
changeset
|
1225 |
|
4023
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1226 |
class GROUP_CONCAT(CONCAT_STRINGS): |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1227 |
supported_backends = ('mysql', 'postgres', 'sqlite',) |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1228 |
|
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1229 |
register_function(GROUP_CONCAT) |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1230 |
|
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1231 |
|
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1232 |
class LIMIT_SIZE(FunctionDescr): |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1233 |
supported_backends = ('postgres', 'sqlite',) |
7691
c47dcd37d4e3
[rql] fix min/max args definition of [TEXT_]LIMIT_SIZE registered procedures (long outstanding bug discovered after recent fix in lgdb)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7264
diff
changeset
|
1234 |
minargs = maxargs = 3 |
4023
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1235 |
rtype = 'String' |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1236 |
|
4831
c5aec27c1bf7
[repo] use logilab.db instead of lgc.adbh/lgc.db/lgc.sqlgen/indexer, test new date extranction functions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4624
diff
changeset
|
1237 |
def st_description(self, funcnode, mainindex, tr): |
4023
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1238 |
return funcnode.children[0].get_description(mainindex, tr) |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1239 |
|
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1240 |
register_function(LIMIT_SIZE) |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1241 |
|
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1242 |
|
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1243 |
class TEXT_LIMIT_SIZE(LIMIT_SIZE): |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1244 |
supported_backends = ('mysql', 'postgres', 'sqlite',) |
7691
c47dcd37d4e3
[rql] fix min/max args definition of [TEXT_]LIMIT_SIZE registered procedures (long outstanding bug discovered after recent fix in lgdb)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7264
diff
changeset
|
1245 |
minargs = maxargs = 2 |
4023
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1246 |
|
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1247 |
register_function(TEXT_LIMIT_SIZE) |
4322
f65743cc53e4
first draft for a simple hooks based custom attribute storage,
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
1248 |
|
f65743cc53e4
first draft for a simple hooks based custom attribute storage,
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
1249 |
|
5768
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
1250 |
class FTIRANK(FunctionDescr): |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
1251 |
"""return ranking of a variable that must be used as some has_text |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
1252 |
relation subject in the query's restriction. Usually used to sort result |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
1253 |
of full-text search by ranking. |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
1254 |
""" |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
1255 |
supported_backends = ('postgres',) |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
1256 |
rtype = 'Float' |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
1257 |
|
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
1258 |
def st_check_backend(self, backend, funcnode): |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
1259 |
"""overriden so that on backend not supporting fti ranking, the |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
1260 |
function is removed when in an orderby clause, or replaced by a 1.0 |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
1261 |
constant. |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
1262 |
""" |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
1263 |
if not self.supports(backend): |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
1264 |
parent = funcnode.parent |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
1265 |
while parent is not None and not isinstance(parent, SortTerm): |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
1266 |
parent = parent.parent |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
1267 |
if isinstance(parent, SortTerm): |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
1268 |
parent.parent.remove(parent) |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
1269 |
else: |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
1270 |
funcnode.parent.replace(funcnode, Constant(1.0, 'Float')) |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
1271 |
parent = funcnode |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
1272 |
for vref in parent.iget_nodes(VariableRef): |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
1273 |
vref.unregister_reference() |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
1274 |
|
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
1275 |
register_function(FTIRANK) |
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
1276 |
|
1e73a466aa69
[fti] support for fti ranking: has_text query results sorted by relevance, and provides a way to control weight per entity / entity's attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5655
diff
changeset
|
1277 |
|
4322
f65743cc53e4
first draft for a simple hooks based custom attribute storage,
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
1278 |
class FSPATH(FunctionDescr): |
5013
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4938
diff
changeset
|
1279 |
"""return path of some bytes attribute stored using the Bytes |
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4938
diff
changeset
|
1280 |
File-System Storage (bfss) |
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4938
diff
changeset
|
1281 |
""" |
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4938
diff
changeset
|
1282 |
rtype = 'Bytes' # XXX return a String? potential pb with fs encoding |
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4938
diff
changeset
|
1283 |
|
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4938
diff
changeset
|
1284 |
def update_cb_stack(self, stack): |
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4938
diff
changeset
|
1285 |
assert len(stack) == 1 |
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4938
diff
changeset
|
1286 |
stack[0] = self.source_execute |
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4938
diff
changeset
|
1287 |
|
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4938
diff
changeset
|
1288 |
def as_sql(self, backend, args): |
6788
0f31ed3fff79
[bfss storage] Improve fspath() error message.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6779
diff
changeset
|
1289 |
raise NotImplementedError( |
0f31ed3fff79
[bfss storage] Improve fspath() error message.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6779
diff
changeset
|
1290 |
'This callback is only available for BytesFileSystemStorage ' |
0f31ed3fff79
[bfss storage] Improve fspath() error message.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6779
diff
changeset
|
1291 |
'managed attribute. Is FSPATH() argument BFSS managed?') |
5013
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4938
diff
changeset
|
1292 |
|
5630
40d7c7e180f1
[storage] source's callback has a new prototype, update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5534
diff
changeset
|
1293 |
def source_execute(self, source, session, value): |
5013
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4938
diff
changeset
|
1294 |
fpath = source.binary_to_str(value) |
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4938
diff
changeset
|
1295 |
try: |
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4938
diff
changeset
|
1296 |
return Binary(fpath) |
8695
358d8bed9626
[toward-py3k] rewrite to "except AnException as exc:" (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
8669
diff
changeset
|
1297 |
except OSError as ex: |
7879
9aae456abab5
[pylint] fix pylint detected errors and tweak it so that pylint -E will be much less verbose next time (+ update some copyrights on the way)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7822
diff
changeset
|
1298 |
source.critical("can't open %s: %s", fpath, ex) |
5013
ad91f93bbb93
[source storage] refactor source sql generation and results handling to allow repository side callbacks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4938
diff
changeset
|
1299 |
return None |
4322
f65743cc53e4
first draft for a simple hooks based custom attribute storage,
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
1300 |
|
f65743cc53e4
first draft for a simple hooks based custom attribute storage,
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
1301 |
register_function(FSPATH) |