author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Fri, 30 Jan 2015 15:43:28 +0100 | |
changeset 10190 | 252e8f7ff9ea |
parent 10084 | eb3681e13ed9 |
child 10273 | ef74abcf369d |
child 10401 | 4f41eb2f06bc |
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 |
|
9917
a98e60464c26
[book] stop talking about the hg `forest` extension
Julien Cristau <julien.cristau@logilab.fr>
parents:
9792
diff
changeset
|
127 |
If you installed *CubicWeb* by cloning the Mercurial shell repository 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 |
9917
a98e60464c26
[book] stop talking about the hg `forest` extension
Julien Cristau <julien.cristau@logilab.fr>
parents:
9792
diff
changeset
|
129 |
adding the path to `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
|
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 |
|
9917
a98e60464c26
[book] stop talking about the hg `forest` extension
Julien Cristau <julien.cristau@logilab.fr>
parents:
9792
diff
changeset
|
134 |
export PYTHONPATH=/full/path/to/grshell-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
|
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', |
|
10012
8c2c6fdd8d56
[RichString] Add markdown support
Christophe de Vienne <christophe@unlish.com>
parents:
9990
diff
changeset
|
281 |
'choices': ('text/plain', 'text/rest', 'text/html', 'text/markdown'), |
0 | 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 |
|
10084
eb3681e13ed9
[config] kill a getattr
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
10012
diff
changeset
|
332 |
quick_start = False |
eb3681e13ed9
[config] kill a getattr
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
10012
diff
changeset
|
333 |
|
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
334 |
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
|
335 |
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
|
336 |
_CUBES_DIR = join(CW_SOFTWARE_ROOT, '../cubes') |
0 | 337 |
else: |
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
338 |
mode = _forced_mode or 'system' |
5022
7e09702aa766
fix _cubes dir
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5021
diff
changeset
|
339 |
_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
|
340 |
|
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
|
341 |
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
|
342 |
CUBES_PATH = os.environ.get('CW_CUBES_PATH', '').split(os.pathsep) |
0 | 343 |
|
1046
52ee022d87e3
simplify registry options to disable some appobjects to use a single option
sylvain.thenault@logilab.fr
parents:
819
diff
changeset
|
344 |
options = ( |
0 | 345 |
('log-threshold', |
346 |
{'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
|
347 |
'default': 'WARNING', |
0 | 348 |
'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
|
349 |
'group': 'main', 'level': 1, |
0 | 350 |
}), |
6779
accf5978a440
[daemon] make process umask configurable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6750
diff
changeset
|
351 |
('umask', |
accf5978a440
[daemon] make process umask configurable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6750
diff
changeset
|
352 |
{'type' : 'int', |
accf5978a440
[daemon] make process umask configurable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6750
diff
changeset
|
353 |
'default': 077, |
accf5978a440
[daemon] make process umask configurable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6750
diff
changeset
|
354 |
'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
|
355 |
'group': 'main', 'level': 2, |
accf5978a440
[daemon] make process umask configurable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6750
diff
changeset
|
356 |
}), |
0 | 357 |
# common configuration options which are potentially required as soon as |
358 |
# you're using "base" application objects (ie to really server/web |
|
359 |
# specific) |
|
360 |
('base-url', |
|
361 |
{'type' : 'string', |
|
362 |
'default': None, |
|
363 |
'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
|
364 |
'group': 'main', 'level': 1, |
0 | 365 |
}), |
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
|
366 |
('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
|
367 |
{'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
|
368 |
'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
|
369 |
'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
|
370 |
'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
|
371 |
}), |
0 | 372 |
('mangle-emails', |
373 |
{'type' : 'yn', |
|
374 |
'default': False, |
|
375 |
'help': "don't display actual email addresses but mangle them if \ |
|
376 |
this option is set to yes", |
|
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
377 |
'group': 'email', 'level': 3, |
0 | 378 |
}), |
379 |
) |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
380 |
# static and class methods used to get instance independant resources ## |
0 | 381 |
@staticmethod |
382 |
def cubicweb_version(): |
|
383 |
"""return installed cubicweb version""" |
|
384 |
from logilab.common.changelog import Version |
|
385 |
from cubicweb import __pkginfo__ |
|
386 |
version = __pkginfo__.numversion |
|
387 |
assert len(version) == 3, version |
|
388 |
return Version(version) |
|
1446 | 389 |
|
0 | 390 |
@staticmethod |
391 |
def persistent_options_configuration(): |
|
392 |
return Configuration(options=PERSISTENT_OPTIONS) |
|
393 |
||
394 |
@classmethod |
|
395 |
def shared_dir(cls): |
|
396 |
"""return the shared data directory (i.e. directory where standard |
|
397 |
library views and data may be found) |
|
398 |
""" |
|
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
|
399 |
if CWDEV: |
0 | 400 |
return join(CW_SOFTWARE_ROOT, 'web') |
1039 | 401 |
return cls.cube_dir('shared') |
1446 | 402 |
|
0 | 403 |
@classmethod |
404 |
def i18n_lib_dir(cls): |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
405 |
"""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
|
406 |
if CWDEV: |
0 | 407 |
return join(CW_SOFTWARE_ROOT, 'i18n') |
408 |
return join(cls.shared_dir(), 'i18n') |
|
409 |
||
410 |
@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
|
411 |
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
|
412 |
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
|
413 |
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
|
414 |
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
|
415 |
|
48f468f33704
[config, i18n] Create default translation mechanism for all supported languages.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6748
diff
changeset
|
416 |
|
48f468f33704
[config, i18n] Create default translation mechanism for all supported languages.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6748
diff
changeset
|
417 |
@classmethod |
0 | 418 |
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
|
419 |
import re |
1015
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
420 |
cubes = set() |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
421 |
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
|
422 |
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
|
423 |
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
|
424 |
% directory) |
4001
bc31ede2085d
dont crash if directory doesn't exist
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3915
diff
changeset
|
425 |
continue |
1015
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
426 |
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
|
427 |
if cube == 'shared': |
5026
1f8238eaec9b
[config] more cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5025
diff
changeset
|
428 |
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
|
429 |
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
|
430 |
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
|
431 |
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
|
432 |
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
|
433 |
cubes.add(cube) |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
434 |
return sorted(cubes) |
1446 | 435 |
|
0 | 436 |
@classmethod |
1015
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
437 |
def cubes_search_path(cls): |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
438 |
"""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
|
439 |
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
|
440 |
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
|
441 |
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
|
442 |
path.append(cls.CUBES_DIR) |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
443 |
return path |
1446 | 444 |
|
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
|
445 |
@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
|
446 |
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
|
447 |
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
|
448 |
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
|
449 |
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
|
450 |
extrapath[cubesdir] = 'cubes' |
4325 | 451 |
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
|
452 |
|
0 | 453 |
@classmethod |
454 |
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
|
455 |
"""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
|
456 |
`ConfigurationError` if it doesn't exist |
0 | 457 |
""" |
1015
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
458 |
for directory in cls.cubes_search_path(): |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
459 |
cubedir = join(directory, cube) |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
460 |
if exists(cubedir): |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
461 |
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
|
462 |
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
|
463 |
cube, cls.cubes_search_path())) |
0 | 464 |
|
465 |
@classmethod |
|
466 |
def cube_migration_scripts_dir(cls, cube): |
|
467 |
"""cube migration scripts directory""" |
|
468 |
return join(cls.cube_dir(cube), 'migration') |
|
1446 | 469 |
|
0 | 470 |
@classmethod |
471 |
def cube_pkginfo(cls, cube): |
|
472 |
"""return the information module for the given cube""" |
|
473 |
cube = CW_MIGRATION_MAP.get(cube, cube) |
|
474 |
try: |
|
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
475 |
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
|
476 |
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
|
477 |
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
|
478 |
raise ConfigurationError( |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
479 |
'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
|
480 |
% (cube, ex.__class__.__name__, ex)) |
0 | 481 |
|
482 |
@classmethod |
|
483 |
def cube_version(cls, cube): |
|
1446 | 484 |
"""return the version of the cube located in the given directory |
0 | 485 |
""" |
486 |
from logilab.common.changelog import Version |
|
487 |
version = cls.cube_pkginfo(cube).numversion |
|
488 |
assert len(version) == 3, version |
|
489 |
return Version(version) |
|
490 |
||
491 |
@classmethod |
|
5025
2826f5406201
deprecate __use__ and __recommend__
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5023
diff
changeset
|
492 |
def _cube_deps(cls, cube, key, oldkey): |
2826f5406201
deprecate __use__ and __recommend__
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5023
diff
changeset
|
493 |
"""return cubicweb cubes used by the given cube""" |
2826f5406201
deprecate __use__ and __recommend__
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5023
diff
changeset
|
494 |
pkginfo = cls.cube_pkginfo(cube) |
2826f5406201
deprecate __use__ and __recommend__
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5023
diff
changeset
|
495 |
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
|
496 |
# explicit __xxx_cubes__ attribute |
5025
2826f5406201
deprecate __use__ and __recommend__
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5023
diff
changeset
|
497 |
deps = getattr(pkginfo, key) |
2826f5406201
deprecate __use__ and __recommend__
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5023
diff
changeset
|
498 |
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
|
499 |
# 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
|
500 |
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
|
501 |
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
|
502 |
except AttributeError: |
9255
46f41c3e1443
remove 3.8 bw compat
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9251
diff
changeset
|
503 |
deps = {} |
5025
2826f5406201
deprecate __use__ and __recommend__
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5023
diff
changeset
|
504 |
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
|
505 |
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
|
506 |
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
|
507 |
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
|
508 |
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
|
509 |
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
|
510 |
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
|
511 |
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
|
512 |
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
|
513 |
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
|
514 |
deps[newname] = deps.pop(depcube) |
5025
2826f5406201
deprecate __use__ and __recommend__
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5023
diff
changeset
|
515 |
return deps |
2826f5406201
deprecate __use__ and __recommend__
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5023
diff
changeset
|
516 |
|
2826f5406201
deprecate __use__ and __recommend__
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5023
diff
changeset
|
517 |
@classmethod |
6659
6205927e927a
fix problem introduced with previous commit
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
6657
diff
changeset
|
518 |
def cube_depends_cubicweb_version(cls, cube): |
6205927e927a
fix problem introduced with previous commit
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
6657
diff
changeset
|
519 |
# 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
|
520 |
try: |
6205927e927a
fix problem introduced with previous commit
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
6657
diff
changeset
|
521 |
pkginfo = cls.cube_pkginfo(cube) |
6205927e927a
fix problem introduced with previous commit
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
6657
diff
changeset
|
522 |
deps = getattr(pkginfo, '__depends__') |
6205927e927a
fix problem introduced with previous commit
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
6657
diff
changeset
|
523 |
return deps.get('cubicweb') |
6205927e927a
fix problem introduced with previous commit
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
6657
diff
changeset
|
524 |
except AttributeError: |
6205927e927a
fix problem introduced with previous commit
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
6657
diff
changeset
|
525 |
return None |
6205927e927a
fix problem introduced with previous commit
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
6657
diff
changeset
|
526 |
|
6205927e927a
fix problem introduced with previous commit
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
6657
diff
changeset
|
527 |
@classmethod |
0 | 528 |
def cube_dependencies(cls, cube): |
529 |
"""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
|
530 |
return cls._cube_deps(cube, '__depends_cubes__', '__use__') |
0 | 531 |
|
532 |
@classmethod |
|
533 |
def cube_recommends(cls, cube): |
|
534 |
"""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
|
535 |
return cls._cube_deps(cube, '__recommends_cubes__', '__recommend__') |
0 | 536 |
|
537 |
@classmethod |
|
2762
b1bb33b37992
[config] new with_recommends option to expand_cubes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2665
diff
changeset
|
538 |
def expand_cubes(cls, cubes, with_recommends=False): |
0 | 539 |
"""expand the given list of top level cubes used by adding recursivly |
540 |
each cube dependencies |
|
541 |
""" |
|
542 |
cubes = list(cubes) |
|
543 |
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
|
544 |
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
|
545 |
available = set(cls.available_cubes()) |
0 | 546 |
while todo: |
547 |
cube = todo.pop(0) |
|
548 |
for depcube in cls.cube_dependencies(cube): |
|
549 |
if depcube not in cubes: |
|
550 |
cubes.append(depcube) |
|
551 |
todo.append(depcube) |
|
2762
b1bb33b37992
[config] new with_recommends option to expand_cubes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2665
diff
changeset
|
552 |
if with_recommends: |
b1bb33b37992
[config] new with_recommends option to expand_cubes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2665
diff
changeset
|
553 |
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
|
554 |
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
|
555 |
cubes.append(depcube) |
b1bb33b37992
[config] new with_recommends option to expand_cubes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2665
diff
changeset
|
556 |
todo.append(depcube) |
0 | 557 |
return cubes |
558 |
||
9669
283503f58400
[cwconfig] Remove useless 'ui-cube' configuration option (closes #3728904)
Rémi Cardona <remi.cardona@logilab.fr>
parents:
9363
diff
changeset
|
559 |
@classmethod |
283503f58400
[cwconfig] Remove useless 'ui-cube' configuration option (closes #3728904)
Rémi Cardona <remi.cardona@logilab.fr>
parents:
9363
diff
changeset
|
560 |
def reorder_cubes(cls, cubes): |
0 | 561 |
"""reorder cubes from the top level cubes to inner dependencies |
562 |
cubes |
|
563 |
""" |
|
5322
c0b7687bce3d
[config] graph ordering function moved to lgc 0.50
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5298
diff
changeset
|
564 |
from logilab.common.graph import ordered_nodes, UnorderableGraph |
0 | 565 |
graph = {} |
566 |
for cube in cubes: |
|
567 |
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
|
568 |
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
|
569 |
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
|
570 |
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
|
571 |
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
|
572 |
try: |
c0b7687bce3d
[config] graph ordering function moved to lgc 0.50
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5298
diff
changeset
|
573 |
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
|
574 |
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
|
575 |
raise ConfigurationError(ex) |
1446 | 576 |
|
0 | 577 |
@classmethod |
578 |
def cls_adjust_sys_path(cls): |
|
579 |
"""update python path if necessary""" |
|
1023
278f997aa257
fix sys.path adjustment
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1015
diff
changeset
|
580 |
cubes_parent_dir = normpath(join(cls.CUBES_DIR, '..')) |
278f997aa257
fix sys.path adjustment
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1015
diff
changeset
|
581 |
if not cubes_parent_dir in sys.path: |
278f997aa257
fix sys.path adjustment
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1015
diff
changeset
|
582 |
sys.path.insert(0, cubes_parent_dir) |
0 | 583 |
try: |
1015
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
584 |
import cubes |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
585 |
cubes.__path__ = cls.cubes_search_path() |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
586 |
except ImportError: |
b5fdad9208f8
search for cubes in a list of directories
sylvain.thenault@logilab.fr
parents:
436
diff
changeset
|
587 |
return # cubes dir doesn't exists |
0 | 588 |
|
589 |
@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
|
590 |
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
|
591 |
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
|
592 |
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
|
593 |
'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
|
594 |
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
|
595 |
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
|
596 |
|
f45f42256905
[config] we should load available configuration before search for an instance configuration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6846
diff
changeset
|
597 |
@classmethod |
0 | 598 |
def load_cwctl_plugins(cls): |
599 |
from logilab.common.modutils import load_module_from_file |
|
600 |
cls.cls_adjust_sys_path() |
|
601 |
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
|
602 |
'server/serverctl.py', |
0 | 603 |
'devtools/devctl.py', 'goa/goactl.py'): |
604 |
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
|
605 |
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
|
606 |
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
|
607 |
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
|
608 |
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
|
609 |
ctlfile, err) |
0 | 610 |
cls.info('loaded cubicweb-ctl plugin %s', ctlfile) |
611 |
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
|
612 |
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
|
613 |
initfile = join(cls.cube_dir(cube), '__init__.py') |
0 | 614 |
if exists(pluginfile): |
615 |
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
|
616 |
__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
|
617 |
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
|
618 |
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
|
619 |
cls.exception('while loading plugin %s', pluginfile) |
0 | 620 |
elif exists(initfile): |
621 |
try: |
|
622 |
__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
|
623 |
except Exception: |
0 | 624 |
cls.exception('while loading cube %s', cube) |
625 |
else: |
|
1446 | 626 |
cls.warning('no __init__ file in cube %s', cube) |
0 | 627 |
|
628 |
@classmethod |
|
629 |
def init_available_cubes(cls): |
|
630 |
"""cubes may register some sources (svnfile for instance) in their |
|
631 |
__init__ file, so they should be loaded early in the startup process |
|
632 |
""" |
|
633 |
for cube in cls.available_cubes(): |
|
634 |
try: |
|
635 |
__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
|
636 |
except Exception as ex: |
0 | 637 |
cls.warning("can't init cube %s: %s", cube, ex) |
1446 | 638 |
|
2657
de974465d381
[appobject] kill VObject class, move base selector classes to appobject
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2654
diff
changeset
|
639 |
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
|
640 |
cube_appobject_path = set(['entities']) |
0 | 641 |
|
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
|
642 |
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
|
643 |
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
|
644 |
# 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
|
645 |
filterwarnings('default', category=DeprecationWarning) |
4023
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
646 |
register_stored_procedures() |
6494
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
647 |
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
|
648 |
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
|
649 |
self.debugmode = debugmode |
0 | 650 |
self.adjust_sys_path() |
651 |
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
|
652 |
# 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
|
653 |
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
|
654 |
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
|
655 |
# 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
|
656 |
# 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
|
657 |
# 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
|
658 |
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
|
659 |
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
|
660 |
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
|
661 |
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
|
662 |
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
|
663 |
cw_rest_init() |
0 | 664 |
|
665 |
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
|
666 |
# overriden in CubicWebConfiguration |
0 | 667 |
self.cls_adjust_sys_path() |
1446 | 668 |
|
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
|
669 |
def init_log(self, logthreshold=None, logfile=None, syslog=False): |
0 | 670 |
"""init the log service""" |
180
8bcebdb5f55d
code moved to logilab.common.logging_ext
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
140
diff
changeset
|
671 |
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
|
672 |
if self.debugmode: |
180
8bcebdb5f55d
code moved to logilab.common.logging_ext
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
140
diff
changeset
|
673 |
logthreshold = 'DEBUG' |
0 | 674 |
else: |
180
8bcebdb5f55d
code moved to logilab.common.logging_ext
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
140
diff
changeset
|
675 |
logthreshold = self['log-threshold'] |
5640
8a6d14f4fb9d
logging settings
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5456
diff
changeset
|
676 |
if sys.platform == 'win32': |
8a6d14f4fb9d
logging settings
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5456
diff
changeset
|
677 |
# no logrotate on win32, so use logging rotation facilities |
8a6d14f4fb9d
logging settings
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5456
diff
changeset
|
678 |
# 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
|
679 |
# idea: make this configurable? |
5655 | 680 |
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
|
681 |
rotation_parameters={'when': 'W6', # every sunday |
5640
8a6d14f4fb9d
logging settings
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5456
diff
changeset
|
682 |
'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
|
683 |
'backupCount': 52}) |
5640
8a6d14f4fb9d
logging settings
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
5456
diff
changeset
|
684 |
else: |
5655 | 685 |
init_log(self.debugmode, syslog, logthreshold, logfile, self.log_format) |
0 | 686 |
# configure simpleTal logger |
687 |
logging.getLogger('simpleTAL').setLevel(logging.ERROR) |
|
688 |
||
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
|
689 |
def appobjects_path(self): |
0 | 690 |
"""return a list of files or directories where the registry will look |
691 |
for application objects. By default return nothing in NoApp config. |
|
692 |
""" |
|
693 |
return [] |
|
1446 | 694 |
|
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
|
695 |
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
|
696 |
"""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
|
697 |
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
|
698 |
|
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 |
: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
|
700 |
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
|
701 |
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
|
702 |
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
|
703 |
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
|
704 |
: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
|
705 |
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
|
706 |
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
|
707 |
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
|
708 |
`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
|
709 |
""" |
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 |
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
|
711 |
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
|
712 |
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
|
713 |
|
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 |
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
|
715 |
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
|
716 |
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
|
717 |
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
|
718 |
# 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
|
719 |
# 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
|
720 |
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
|
721 |
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
|
722 |
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
|
723 |
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
|
724 |
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
|
725 |
|
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 |
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
|
727 |
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
|
728 |
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
|
729 |
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
|
730 |
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
|
731 |
# 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
|
732 |
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
|
733 |
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
|
734 |
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
|
735 |
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
|
736 |
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
|
737 |
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
|
738 |
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
|
739 |
|
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
|
740 |
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
|
741 |
|
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 |
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
|
743 |
"""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
|
744 |
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
|
745 |
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
|
746 |
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
|
747 |
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
|
748 |
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
|
749 |
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
|
750 |
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
|
751 |
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
|
752 |
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
|
753 |
|
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 |
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
|
755 |
# 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
|
756 |
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
|
757 |
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
|
758 |
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
|
759 |
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
|
760 |
|
7031
a04621040cad
[config refactoring] rename eproperty_definition method to cwproperty_definition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7005
diff
changeset
|
761 |
def cwproperty_definitions(self): |
0 | 762 |
cfg = self.persistent_options_configuration() |
763 |
for section, options in cfg.options_by_section(): |
|
764 |
section = section.lower() |
|
765 |
for optname, optdict, value in options: |
|
766 |
key = '%s.%s' % (section, optname) |
|
767 |
type, vocab = self.map_option(optdict) |
|
768 |
default = cfg.option_default(optname, optdict) |
|
769 |
pdef = {'type': type, 'vocabulary': vocab, 'default': default, |
|
770 |
'help': optdict['help'], |
|
771 |
'sitewide': optdict.get('sitewide', False)} |
|
772 |
yield key, pdef |
|
1446 | 773 |
|
0 | 774 |
def map_option(self, optdict): |
775 |
try: |
|
776 |
vocab = optdict['choices'] |
|
777 |
except KeyError: |
|
778 |
vocab = optdict.get('vocabulary') |
|
779 |
if isinstance(vocab, Method): |
|
780 |
vocab = getattr(self, vocab.method, ()) |
|
781 |
return CFGTYPE2ETYPE_MAP[optdict['type']], vocab |
|
782 |
||
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
|
783 |
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
|
784 |
"""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
|
785 |
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
|
786 |
""" |
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
|
787 |
return None |
1446 | 788 |
|
6494
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
789 |
_cubes = None |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
790 |
|
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
791 |
def init_cubes(self, cubes): |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
792 |
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
|
793 |
# 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
|
794 |
for cube in cubes: |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
795 |
__import__('cubes.%s' % cube) |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
796 |
self.load_site_cubicweb() |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
797 |
|
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
798 |
def cubes(self): |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
799 |
"""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
|
800 |
|
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
801 |
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
|
802 |
cubes |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
803 |
""" |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
804 |
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
|
805 |
return self._cubes |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
806 |
|
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
807 |
def cubes_path(self): |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
808 |
"""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
|
809 |
most to inner most cubes |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
810 |
""" |
70c87c717e4a
[config] make config.cubes() available on NoAppCubicWebConfiguration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6397
diff
changeset
|
811 |
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
|
812 |
|
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
|
813 |
# 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
|
814 |
# 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
|
815 |
@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
|
816 |
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
|
817 |
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
|
818 |
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
|
819 |
|
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
820 |
|
0 | 821 |
class CubicWebConfiguration(CubicWebNoAppConfiguration): |
822 |
"""base class for cubicweb server and web configurations""" |
|
1446 | 823 |
|
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
824 |
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
|
825 |
_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
|
826 |
#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
|
827 |
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
|
828 |
_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
|
829 |
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
|
830 |
_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
|
831 |
|
7129
455b503fb7ff
[config] generalise config.creating, allowing to drop set_language class attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7086
diff
changeset
|
832 |
# 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
|
833 |
# 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
|
834 |
repairing = False |
1446 | 835 |
|
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
|
836 |
# 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
|
837 |
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
|
838 |
|
0 | 839 |
options = CubicWebNoAppConfiguration.options + ( |
840 |
('log-file', |
|
841 |
{'type' : 'string', |
|
842 |
'default': Method('default_log_file'), |
|
843 |
'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
|
844 |
'group': 'main', 'level': 2, |
0 | 845 |
}), |
846 |
# email configuration |
|
847 |
('smtp-host', |
|
848 |
{'type' : 'string', |
|
849 |
'default': 'mail', |
|
850 |
'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
|
851 |
'group': 'email', 'level': 1, |
0 | 852 |
}), |
853 |
('smtp-port', |
|
854 |
{'type' : 'int', |
|
855 |
'default': 25, |
|
856 |
'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
|
857 |
'group': 'email', 'level': 1, |
0 | 858 |
}), |
859 |
('sender-name', |
|
860 |
{'type' : 'string', |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
861 |
'default': Method('default_instance_id'), |
0 | 862 |
'help': 'name used as HELO name for outgoing emails from the \ |
863 |
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
|
864 |
'group': 'email', 'level': 2, |
0 | 865 |
}), |
866 |
('sender-addr', |
|
867 |
{'type' : 'string', |
|
2351
dddee537e4d5
don't use internal address
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2267
diff
changeset
|
868 |
'default': 'cubicweb@mydomain.com', |
0 | 869 |
'help': 'email address used as HELO address for outgoing emails from \ |
870 |
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
|
871 |
'group': 'email', 'level': 1, |
0 | 872 |
}), |
873 |
) |
|
874 |
||
875 |
@classmethod |
|
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
876 |
def instances_dir(cls): |
0 | 877 |
"""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
|
878 |
return abspath(os.environ.get('CW_INSTANCES_DIR', cls._INSTANCES_DIR)) |
1446 | 879 |
|
0 | 880 |
@classmethod |
881 |
def migration_scripts_dir(cls): |
|
882 |
"""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
|
883 |
if CWDEV: |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
884 |
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
|
885 |
mdir = join(_INSTALL_PREFIX, 'share', 'cubicweb', 'migration') |
5028 | 886 |
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
|
887 |
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
|
888 |
return mdir |
0 | 889 |
|
890 |
@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
|
891 |
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
|
892 |
"""return a configuration instance for the given instance identifier |
0 | 893 |
""" |
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
|
894 |
cls.load_available_configs() |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
895 |
config = config or guess_configuration(cls.instance_home(appid)) |
0 | 896 |
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
|
897 |
return configcls(appid, debugmode, creating) |
1446 | 898 |
|
0 | 899 |
@classmethod |
900 |
def possible_configurations(cls, appid): |
|
901 |
"""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
|
902 |
instance id |
0 | 903 |
""" |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
904 |
home = cls.instance_home(appid) |
0 | 905 |
return possible_configurations(home) |
1446 | 906 |
|
0 | 907 |
@classmethod |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
908 |
def instance_home(cls, appid): |
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
909 |
"""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
|
910 |
instance id |
0 | 911 |
""" |
5021
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
912 |
home = join(cls.instances_dir(), appid) |
0 | 913 |
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
|
914 |
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
|
915 |
' "cubicweb-ctl list")' % appid) |
0 | 916 |
return home |
917 |
||
9251
e4d753c8b1c4
remove "twisted" configuration (closes #2919310)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8850
diff
changeset
|
918 |
MODES = ('common', 'repository', 'Any') |
0 | 919 |
MCOMPAT = {'all-in-one': MODES, |
9251
e4d753c8b1c4
remove "twisted" configuration (closes #2919310)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8850
diff
changeset
|
920 |
'repository': ('common', 'repository', 'Any')} |
0 | 921 |
@classmethod |
922 |
def accept_mode(cls, mode): |
|
923 |
#assert mode in cls.MODES, mode |
|
924 |
return mode in cls.MCOMPAT[cls.name] |
|
1446 | 925 |
|
0 | 926 |
# default configuration methods ########################################### |
1446 | 927 |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
928 |
def default_instance_id(self): |
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
929 |
"""return the instance identifier, useful for option which need this |
0 | 930 |
as default value |
931 |
""" |
|
932 |
return self.appid |
|
933 |
||
934 |
def default_log_file(self): |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
935 |
"""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
|
936 |
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
|
937 |
import tempfile |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
938 |
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
|
939 |
basename(self.appid), self.name)) |
0 | 940 |
path = basepath + '.log' |
941 |
i = 1 |
|
942 |
while exists(path) and i < 100: # arbitrary limit to avoid infinite loop |
|
943 |
try: |
|
944 |
file(path, 'a') |
|
945 |
break |
|
946 |
except IOError: |
|
947 |
path = '%s-%s.log' % (basepath, i) |
|
948 |
i += 1 |
|
949 |
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
|
950 |
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
|
951 |
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
|
952 |
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
|
953 |
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
|
954 |
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
|
955 |
|
0 | 956 |
def default_pid_file(self): |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
957 |
"""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
|
958 |
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
|
959 |
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
|
960 |
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
|
961 |
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
|
962 |
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
|
963 |
else: |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
964 |
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
|
965 |
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
|
966 |
# 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
|
967 |
# 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
|
968 |
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
|
969 |
return join(rtdir, '%s-%s.pid' % (self.appid, self.name)) |
1446 | 970 |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
971 |
# instance methods used to get instance specific resources ############# |
1446 | 972 |
|
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 |
def __init__(self, appid, debugmode=False, creating=False): |
0 | 974 |
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
|
975 |
# 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
|
976 |
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
|
977 |
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
|
978 |
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
|
979 |
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
|
980 |
self.translations[lang] = fake_gettext |
0 | 981 |
self._cubes = None |
982 |
self.load_file_configuration(self.main_config_file()) |
|
983 |
||
984 |
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
|
985 |
super(CubicWebConfiguration, self).adjust_sys_path() |
0 | 986 |
# adding apphome to python path is not usually necessary in production |
987 |
# 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
|
988 |
if self.apphome and self.apphome not in sys.path: |
0 | 989 |
sys.path.insert(0, self.apphome) |
990 |
||
991 |
@property |
|
992 |
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
|
993 |
return join(self.instances_dir(), self.appid) |
1446 | 994 |
|
0 | 995 |
@property |
996 |
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
|
997 |
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
|
998 |
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
|
999 |
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
|
1000 |
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
|
1001 |
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
|
1002 |
else: |
58e89f3dfbae
handle nicely typical installation other than debian package / mercurial forest
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5013
diff
changeset
|
1003 |
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
|
1004 |
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
|
1005 |
return join(iddir, self.appid) |
1446 | 1006 |
|
0 | 1007 |
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
|
1008 |
super(CubicWebConfiguration, self).init_cubes(cubes) |
0 | 1009 |
# reload config file in cases options are defined in cubes __init__ |
1010 |
# or site_cubicweb files |
|
1011 |
self.load_file_configuration(self.main_config_file()) |
|
1012 |
# configuration initialization hook |
|
1013 |
self.load_configuration() |
|
1446 | 1014 |
|
0 | 1015 |
def add_cubes(self, cubes): |
1016 |
"""add given cubes to the list of used cubes""" |
|
1017 |
if not isinstance(cubes, list): |
|
1018 |
cubes = list(cubes) |
|
1019 |
self._cubes = self.reorder_cubes(list(self._cubes) + cubes) |
|
1446 | 1020 |
|
0 | 1021 |
def main_config_file(self): |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
1022 |
"""return instance's control configuration file""" |
0 | 1023 |
return join(self.apphome, '%s.conf' % self.name) |
1446 | 1024 |
|
0 | 1025 |
def save(self): |
1026 |
"""write down current configuration""" |
|
1027 |
self.generate_config(open(self.main_config_file(), 'w')) |
|
1028 |
||
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
|
1029 |
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
|
1030 |
"""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
|
1031 |
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
|
1032 |
|
6135
e4b37742f75a
[win32] no os.getuid on windows
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
6087
diff
changeset
|
1033 |
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
|
1034 |
""" |
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
|
1035 |
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
|
1036 |
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
|
1037 |
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
|
1038 |
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
|
1039 |
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
|
1040 |
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
|
1041 |
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
|
1042 |
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
|
1043 |
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
|
1044 |
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
|
1045 |
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
|
1046 |
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
|
1047 |
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
|
1048 |
else: |
6135
e4b37742f75a
[win32] no os.getuid on windows
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
6087
diff
changeset
|
1049 |
try: |
e4b37742f75a
[win32] no os.getuid on windows
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
6087
diff
changeset
|
1050 |
uid = os.getuid() |
e4b37742f75a
[win32] no os.getuid on windows
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
6087
diff
changeset
|
1051 |
except AttributeError: # we are on windows |
e4b37742f75a
[win32] no os.getuid on windows
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
6087
diff
changeset
|
1052 |
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
|
1053 |
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
|
1054 |
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
|
1055 |
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
|
1056 |
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
|
1057 |
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
|
1058 |
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
|
1059 |
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
|
1060 |
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
|
1061 |
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
|
1062 |
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
|
1063 |
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
|
1064 |
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
|
1065 |
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
|
1066 |
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
|
1067 |
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
|
1068 |
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
|
1069 |
|
0 | 1070 |
@cached |
1071 |
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
|
1072 |
from hashlib import md5 # pylint: disable=E0611 |
0 | 1073 |
infos = [] |
7264
9ed9e1d77ef3
[web config] fix md5 version to ensure cubes order and to include cubicweb version
Florent Cayré
parents:
7179
diff
changeset
|
1074 |
for pkg in sorted(self.cubes()): |
0 | 1075 |
version = self.cube_version(pkg) |
1076 |
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
|
1077 |
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
|
1078 |
return md5(';'.join(infos)).hexdigest() |
1446 | 1079 |
|
0 | 1080 |
def load_configuration(self): |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
1081 |
"""load instance's configuration files""" |
0 | 1082 |
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
|
1083 |
if self.apphome and not self.creating: |
0 | 1084 |
# 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
|
1085 |
self._gettext_init() |
1446 | 1086 |
|
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
|
1087 |
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
|
1088 |
# 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
|
1089 |
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
|
1090 |
if getattr(mod, 'options', None): |
5817
e4207221f3f5
[config] fix dumb name error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5812
diff
changeset
|
1091 |
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
|
1092 |
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
|
1093 |
|
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
|
1094 |
def init_log(self, logthreshold=None, force=False): |
0 | 1095 |
"""init the log service""" |
1096 |
if not force and hasattr(self, '_logging_initialized'): |
|
1097 |
return |
|
1098 |
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
|
1099 |
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
|
1100 |
super_self.init_log(logthreshold, logfile=self.get('log-file')) |
0 | 1101 |
# read a config file if it exists |
1102 |
logconfig = join(self.apphome, 'logging.conf') |
|
1103 |
if exists(logconfig): |
|
7178
a62f24e1497e
fileConfig is in logging.config
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7086
diff
changeset
|
1104 |
logging.config.fileConfig(logconfig) |
0 | 1105 |
|
1106 |
def available_languages(self, *args): |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
1107 |
"""return available translation for an instance, by looking for |
0 | 1108 |
compiled catalog |
1109 |
||
4936
a4b772a0d801
Fixed some of the documentation warnings when building the book with sphinx.
Adrien Chauve <adrien.chauve@logilab.fr>
parents:
4889
diff
changeset
|
1110 |
take \*args to be usable as a vocabulary method |
0 | 1111 |
""" |
1112 |
from glob import glob |
|
1113 |
yield 'en' # ensure 'en' is yielded even if no .mo found |
|
1114 |
for path in glob(join(self.apphome, 'i18n', |
|
3118 | 1115 |
'*', 'LC_MESSAGES')): |
1116 |
lang = path.split(os.sep)[-2] |
|
0 | 1117 |
if lang != 'en': |
1118 |
yield lang |
|
1446 | 1119 |
|
5444
f7fdb5dd82f6
[webconfig] introduce property sheets. Use them to replace external_resources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5442
diff
changeset
|
1120 |
def _gettext_init(self): |
0 | 1121 |
"""set language for gettext""" |
8106
241123f7bcd0
[cwconfig] absolute import (closes #2091068)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8031
diff
changeset
|
1122 |
from cubicweb.gettext import translation |
0 | 1123 |
path = join(self.apphome, 'i18n') |
1124 |
for language in self.available_languages(): |
|
1125 |
self.info("loading language %s", language) |
|
1126 |
try: |
|
1127 |
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
|
1128 |
self.translations[language] = (tr.ugettext, tr.upgettext) |
0 | 1129 |
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
|
1130 |
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
|
1131 |
# 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
|
1132 |
# 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
|
1133 |
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
|
1134 |
language) |
1446 | 1135 |
|
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
|
1136 |
def appobjects_path(self): |
0 | 1137 |
"""return a list of files or directories where the registry will look |
1138 |
for application objects |
|
1139 |
""" |
|
1140 |
templpath = list(reversed(self.cubes_path())) |
|
1141 |
if self.apphome: # may be unset in tests |
|
1142 |
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
|
1143 |
return self.build_appobjects_path(templpath) |
0 | 1144 |
|
1145 |
def set_sources_mode(self, sources): |
|
1146 |
if not 'all' in sources: |
|
1147 |
print 'warning: ignoring specified sources, requires a repository '\ |
|
1148 |
'configuration' |
|
1446 | 1149 |
|
0 | 1150 |
def migration_handler(self): |
1151 |
"""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
|
1152 |
from cubicweb.migration import MigrationHelper |
0 | 1153 |
return MigrationHelper(self, verbosity=self.verbosity) |
1154 |
||
1155 |
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
|
1156 |
from cubicweb import i18n |
0 | 1157 |
if langs is None: |
1158 |
langs = self.available_languages() |
|
1159 |
i18ndir = join(self.apphome, 'i18n') |
|
1160 |
if not exists(i18ndir): |
|
1161 |
create_dir(i18ndir) |
|
1162 |
sourcedirs = [join(path, 'i18n') for path in self.cubes_path()] |
|
1163 |
sourcedirs.append(self.i18n_lib_dir()) |
|
1164 |
return i18n.compile_i18n_catalogs(sourcedirs, i18ndir, langs) |
|
1165 |
||
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
|
1166 |
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
|
1167 |
"""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
|
1168 |
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
|
1169 |
""" |
2221
d9b85a7b0bdd
create sendmails method on cwconfig, use it in SendMailOp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2220
diff
changeset
|
1170 |
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
|
1171 |
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
|
1172 |
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
|
1173 |
SMTP_LOCK.acquire() |
d9b85a7b0bdd
create sendmails method on cwconfig, use it in SendMailOp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2220
diff
changeset
|
1174 |
try: |
d9b85a7b0bdd
create sendmails method on cwconfig, use it in SendMailOp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2220
diff
changeset
|
1175 |
try: |
d9b85a7b0bdd
create sendmails method on cwconfig, use it in SendMailOp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2220
diff
changeset
|
1176 |
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
|
1177 |
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
|
1178 |
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
|
1179 |
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
|
1180 |
return False |
2221
d9b85a7b0bdd
create sendmails method on cwconfig, use it in SendMailOp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2220
diff
changeset
|
1181 |
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
|
1182 |
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
|
1183 |
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
|
1184 |
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
|
1185 |
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
|
1186 |
recipients, ex) |
d9b85a7b0bdd
create sendmails method on cwconfig, use it in SendMailOp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2220
diff
changeset
|
1187 |
smtp.close() |
d9b85a7b0bdd
create sendmails method on cwconfig, use it in SendMailOp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2220
diff
changeset
|
1188 |
finally: |
d9b85a7b0bdd
create sendmails method on cwconfig, use it in SendMailOp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2220
diff
changeset
|
1189 |
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
|
1190 |
return True |
2221
d9b85a7b0bdd
create sendmails method on cwconfig, use it in SendMailOp
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2220
diff
changeset
|
1191 |
|
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
|
1192 |
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
|
1193 |
logging.getLogger('cubicweb.configuration')) |
1446 | 1194 |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2473
diff
changeset
|
1195 |
# 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
|
1196 |
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
|
1197 |
application_configuration = deprecated('use instance_configuration')(instance_configuration) |
4023
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1198 |
|
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1199 |
|
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1200 |
_EXT_REGISTERED = False |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1201 |
def register_stored_procedures(): |
4848
41f84eea63c9
rename logilab.db into logilab.database
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4831
diff
changeset
|
1202 |
from logilab.database import FunctionDescr |
4023
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1203 |
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
|
1204 |
from rql.nodes import SortTerm, Constant, VariableRef |
4023
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1205 |
|
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1206 |
global _EXT_REGISTERED |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1207 |
if _EXT_REGISTERED: |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1208 |
return |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1209 |
_EXT_REGISTERED = True |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1210 |
|
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1211 |
class COMMA_JOIN(FunctionDescr): |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1212 |
supported_backends = ('postgres', 'sqlite',) |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1213 |
rtype = 'String' |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1214 |
|
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
|
1215 |
def st_description(self, funcnode, mainindex, tr): |
4023
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1216 |
return ', '.join(sorted(term.get_description(mainindex, tr) |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1217 |
for term in iter_funcnode_variables(funcnode))) |
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 |
register_function(COMMA_JOIN) # XXX do not expose? |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1220 |
|
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1221 |
|
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1222 |
class CONCAT_STRINGS(COMMA_JOIN): |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1223 |
aggregat = True |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1224 |
|
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1225 |
register_function(CONCAT_STRINGS) # XXX bw compat |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1226 |
|
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
|
1227 |
|
4023
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1228 |
class GROUP_CONCAT(CONCAT_STRINGS): |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1229 |
supported_backends = ('mysql', 'postgres', 'sqlite',) |
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 |
register_function(GROUP_CONCAT) |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1232 |
|
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1233 |
|
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1234 |
class LIMIT_SIZE(FunctionDescr): |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1235 |
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
|
1236 |
minargs = maxargs = 3 |
4023
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1237 |
rtype = 'String' |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1238 |
|
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
|
1239 |
def st_description(self, funcnode, mainindex, tr): |
4023
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1240 |
return funcnode.children[0].get_description(mainindex, tr) |
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 |
register_function(LIMIT_SIZE) |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1243 |
|
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1244 |
|
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1245 |
class TEXT_LIMIT_SIZE(LIMIT_SIZE): |
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1246 |
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
|
1247 |
minargs = maxargs = 2 |
4023
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1248 |
|
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4021
diff
changeset
|
1249 |
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
|
1250 |
|
f65743cc53e4
first draft for a simple hooks based custom attribute storage,
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
1251 |
|
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
|
1252 |
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
|
1253 |
"""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
|
1254 |
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
|
1255 |
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
|
1256 |
""" |
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 |
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
|
1258 |
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
|
1259 |
|
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 |
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
|
1261 |
"""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
|
1262 |
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
|
1263 |
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
|
1264 |
""" |
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 |
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
|
1266 |
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
|
1267 |
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
|
1268 |
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
|
1269 |
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
|
1270 |
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
|
1271 |
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
|
1272 |
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
|
1273 |
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
|
1274 |
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
|
1275 |
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
|
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 |
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
|
1278 |
|
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
|
1279 |
|
4322
f65743cc53e4
first draft for a simple hooks based custom attribute storage,
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
1280 |
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
|
1281 |
"""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
|
1282 |
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
|
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 |
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
|
1285 |
|
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 |
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
|
1287 |
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
|
1288 |
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
|
1289 |
|
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
|
1290 |
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
|
1291 |
raise NotImplementedError( |
0f31ed3fff79
[bfss storage] Improve fspath() error message.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
6779
diff
changeset
|
1292 |
'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
|
1293 |
'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
|
1294 |
|
5630
40d7c7e180f1
[storage] source's callback has a new prototype, update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5534
diff
changeset
|
1295 |
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
|
1296 |
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
|
1297 |
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
|
1298 |
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
|
1299 |
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
|
1300 |
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
|
1301 |
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
|
1302 |
|
f65743cc53e4
first draft for a simple hooks based custom attribute storage,
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
1303 |
register_function(FSPATH) |