author | Aurelien Campeas <aurelien.campeas@logilab.fr> |
Thu, 12 Jun 2014 18:31:21 +0200 | |
changeset 10110 | f601d2fdeff7 |
parent 9468 | 39b7a91a3f4c |
child 10233 | f7dfcb3add15 |
child 10235 | 684215aca046 |
permissions | -rw-r--r-- |
9468
39b7a91a3f4c
[repo] pylint cleanup, mainly of imports, with a bit of style
Julien Cristau <julien.cristau@logilab.fr>
parents:
9460
diff
changeset
|
1 |
# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5326
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5326
diff
changeset
|
3 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5326
diff
changeset
|
4 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5326
diff
changeset
|
5 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5326
diff
changeset
|
6 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5326
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5326
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5326
diff
changeset
|
9 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5326
diff
changeset
|
10 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5326
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5326
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5326
diff
changeset
|
14 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5326
diff
changeset
|
15 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5326
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5326
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
5933
3d707b8f8a4d
[web configuration] ensure data home directory / uicache file belong to daemon user and are writeable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5456
diff
changeset
|
18 |
"""server.serverconfig definition""" |
0 | 19 |
|
20 |
__docformat__ = "restructuredtext en" |
|
21 |
||
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
22 |
import sys |
0 | 23 |
from os.path import join, exists |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
24 |
from StringIO import StringIO |
0 | 25 |
|
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
26 |
import logilab.common.configuration as lgconfig |
9468
39b7a91a3f4c
[repo] pylint cleanup, mainly of imports, with a bit of style
Julien Cristau <julien.cristau@logilab.fr>
parents:
9460
diff
changeset
|
27 |
from logilab.common.decorators import cached |
0 | 28 |
|
3637 | 29 |
from cubicweb.toolsutils import read_config, restrict_perms_to_user |
8989
8742f4bf029f
import merge_options directly from logilab.common
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
8988
diff
changeset
|
30 |
from cubicweb.cwconfig import CONFIGURATIONS, CubicWebConfiguration |
2107
6c4a4c514ac2
add source to sources configuration when adding a cube defining a source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2105
diff
changeset
|
31 |
from cubicweb.server import SOURCE_TYPES |
0 | 32 |
|
33 |
||
2107
6c4a4c514ac2
add source to sources configuration when adding a cube defining a source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2105
diff
changeset
|
34 |
USER_OPTIONS = ( |
6c4a4c514ac2
add source to sources configuration when adding a cube defining a source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2105
diff
changeset
|
35 |
('login', {'type' : 'string', |
3835
a191b3b9e455
more sensible default values to c-c "create" inputs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3638
diff
changeset
|
36 |
'default': 'admin', |
2107
6c4a4c514ac2
add source to sources configuration when adding a cube defining a source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2105
diff
changeset
|
37 |
'help': "cubicweb manager account's login " |
6c4a4c514ac2
add source to sources configuration when adding a cube defining a source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2105
diff
changeset
|
38 |
'(this user will be created)', |
5323
329b4f6d18b4
[config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5059
diff
changeset
|
39 |
'level': 0, |
2107
6c4a4c514ac2
add source to sources configuration when adding a cube defining a source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2105
diff
changeset
|
40 |
}), |
6c4a4c514ac2
add source to sources configuration when adding a cube defining a source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2105
diff
changeset
|
41 |
('password', {'type' : 'password', |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
42 |
'default': lgconfig.REQUIRED, |
2107
6c4a4c514ac2
add source to sources configuration when adding a cube defining a source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2105
diff
changeset
|
43 |
'help': "cubicweb manager account's password", |
5323
329b4f6d18b4
[config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5059
diff
changeset
|
44 |
'level': 0, |
2107
6c4a4c514ac2
add source to sources configuration when adding a cube defining a source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2105
diff
changeset
|
45 |
}), |
6c4a4c514ac2
add source to sources configuration when adding a cube defining a source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2105
diff
changeset
|
46 |
) |
6c4a4c514ac2
add source to sources configuration when adding a cube defining a source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2105
diff
changeset
|
47 |
|
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
48 |
class SourceConfiguration(lgconfig.Configuration): |
6299
51a9494b5efb
[sqlite] quick hacks to fix #1251873 and #1251874
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6128
diff
changeset
|
49 |
def __init__(self, appconfig, options): |
51a9494b5efb
[sqlite] quick hacks to fix #1251873 and #1251874
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6128
diff
changeset
|
50 |
self.appconfig = appconfig # has to be done before super call |
3904
dc7d315165fc
default_instance id should also be available when silently rebuilding soures file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3900
diff
changeset
|
51 |
super(SourceConfiguration, self).__init__(options=options) |
dc7d315165fc
default_instance id should also be available when silently rebuilding soures file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3900
diff
changeset
|
52 |
|
dc7d315165fc
default_instance id should also be available when silently rebuilding soures file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3900
diff
changeset
|
53 |
# make Method('default_instance_id') usable in db option defs (in native.py) |
3905 | 54 |
def default_instance_id(self): |
6299
51a9494b5efb
[sqlite] quick hacks to fix #1251873 and #1251874
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6128
diff
changeset
|
55 |
return self.appconfig.appid |
3904
dc7d315165fc
default_instance id should also be available when silently rebuilding soures file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3900
diff
changeset
|
56 |
|
6299
51a9494b5efb
[sqlite] quick hacks to fix #1251873 and #1251874
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6128
diff
changeset
|
57 |
def input_option(self, option, optdict, inputlevel): |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
58 |
try: |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
59 |
dbdriver = self['db-driver'] |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
60 |
except lgconfig.OptionError: |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
61 |
pass |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
62 |
else: |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
63 |
if dbdriver == 'sqlite': |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
64 |
if option in ('db-user', 'db-password'): |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
65 |
return |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
66 |
if option == 'db-name': |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
67 |
optdict = optdict.copy() |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
68 |
optdict['help'] = 'path to the sqlite database' |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
69 |
optdict['default'] = join(self.appconfig.appdatahome, |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
70 |
self.appconfig.appid + '.sqlite') |
6299
51a9494b5efb
[sqlite] quick hacks to fix #1251873 and #1251874
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6128
diff
changeset
|
71 |
super(SourceConfiguration, self).input_option(option, optdict, inputlevel) |
51a9494b5efb
[sqlite] quick hacks to fix #1251873 and #1251874
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6128
diff
changeset
|
72 |
|
51a9494b5efb
[sqlite] quick hacks to fix #1251873 and #1251874
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6128
diff
changeset
|
73 |
|
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
74 |
|
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
75 |
def ask_source_config(appconfig, type, inputlevel=0): |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
76 |
options = SOURCE_TYPES[type].options |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
77 |
sconfig = SourceConfiguration(appconfig, options=options) |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
78 |
sconfig.input_config(inputlevel=inputlevel) |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
79 |
return sconfig |
2105
92ea410806fe
refactor sources configuration, add source to sources when using a cube defining
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
80 |
|
6627
430b7703b3fd
[sources] method to ease modification of a source config through c-c shell
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6478
diff
changeset
|
81 |
def generate_source_config(sconfig, encoding=sys.stdin.encoding): |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
82 |
"""serialize a repository source configuration as text""" |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
83 |
stream = StringIO() |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
84 |
optsbysect = list(sconfig.options_by_section()) |
8708
78a99960286a
[ldapfeed] all options of a source should be in the same group, else you get AssertionError on c-c add-source. Closes #2538398
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8670
diff
changeset
|
85 |
assert len(optsbysect) == 1, ( |
78a99960286a
[ldapfeed] all options of a source should be in the same group, else you get AssertionError on c-c add-source. Closes #2538398
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8670
diff
changeset
|
86 |
'all options for a source should be in the same group, got %s' |
78a99960286a
[ldapfeed] all options of a source should be in the same group, else you get AssertionError on c-c add-source. Closes #2538398
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8670
diff
changeset
|
87 |
% [x[0] for x in optsbysect]) |
6627
430b7703b3fd
[sources] method to ease modification of a source config through c-c shell
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6478
diff
changeset
|
88 |
lgconfig.ini_format(stream, optsbysect[0][1], encoding) |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
89 |
return stream.getvalue() |
2105
92ea410806fe
refactor sources configuration, add source to sources when using a cube defining
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
90 |
|
92ea410806fe
refactor sources configuration, add source to sources when using a cube defining
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
91 |
|
0 | 92 |
class ServerConfiguration(CubicWebConfiguration): |
93 |
"""standalone RQL server""" |
|
94 |
name = 'repository' |
|
95 |
||
2835
04034421b072
[hooks] major refactoring:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2810
diff
changeset
|
96 |
cubicweb_appobject_path = CubicWebConfiguration.cubicweb_appobject_path | set(['sobjects', 'hooks']) |
2657
de974465d381
[appobject] kill VObject class, move base selector classes to appobject
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
97 |
cube_appobject_path = CubicWebConfiguration.cube_appobject_path | set(['sobjects', 'hooks']) |
0 | 98 |
|
8989
8742f4bf029f
import merge_options directly from logilab.common
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
8988
diff
changeset
|
99 |
options = lgconfig.merge_options(( |
0 | 100 |
# ctl configuration |
101 |
('host', |
|
102 |
{'type' : 'string', |
|
103 |
'default': None, |
|
104 |
'help': 'host name if not correctly detectable through gethostname', |
|
5323
329b4f6d18b4
[config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5059
diff
changeset
|
105 |
'group': 'main', 'level': 1, |
0 | 106 |
}), |
107 |
('pid-file', |
|
108 |
{'type' : 'string', |
|
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
109 |
'default': lgconfig.Method('default_pid_file'), |
0 | 110 |
'help': 'repository\'s pid file', |
5323
329b4f6d18b4
[config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5059
diff
changeset
|
111 |
'group': 'main', 'level': 2, |
0 | 112 |
}), |
113 |
('uid', |
|
114 |
{'type' : 'string', |
|
115 |
'default': None, |
|
116 |
'help': 'if this option is set, use the specified user to start \ |
|
117 |
the repository rather than the user running the command', |
|
5323
329b4f6d18b4
[config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5059
diff
changeset
|
118 |
'group': 'main', 'level': (CubicWebConfiguration.mode == 'installed') and 0 or 1, |
0 | 119 |
}), |
6012
d56fd78006cd
[session] cleanup session-time / cleanup-session-time...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5933
diff
changeset
|
120 |
('cleanup-session-time', |
5326
0d9054eb3bd1
[config] properly use time type for options representing a time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5059
diff
changeset
|
121 |
{'type' : 'time', |
6012
d56fd78006cd
[session] cleanup session-time / cleanup-session-time...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5933
diff
changeset
|
122 |
'default': '24h', |
d56fd78006cd
[session] cleanup session-time / cleanup-session-time...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5933
diff
changeset
|
123 |
'help': 'duration of inactivity after which a session ' |
d56fd78006cd
[session] cleanup session-time / cleanup-session-time...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5933
diff
changeset
|
124 |
'will be closed, to limit memory consumption (avoid sessions that ' |
d56fd78006cd
[session] cleanup session-time / cleanup-session-time...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5933
diff
changeset
|
125 |
'never expire and cause memory leak when http-session-time is 0, or ' |
d56fd78006cd
[session] cleanup session-time / cleanup-session-time...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5933
diff
changeset
|
126 |
'because of bad client that never closes their connection). ' |
d56fd78006cd
[session] cleanup session-time / cleanup-session-time...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5933
diff
changeset
|
127 |
'So notice that even if http-session-time is 0 and the user don\'t ' |
d56fd78006cd
[session] cleanup session-time / cleanup-session-time...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5933
diff
changeset
|
128 |
'close his browser, he will have to reauthenticate after this time ' |
d56fd78006cd
[session] cleanup session-time / cleanup-session-time...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5933
diff
changeset
|
129 |
'of inactivity. Default to 24h.', |
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
130 |
'group': 'main', 'level': 3, |
0 | 131 |
}), |
132 |
('connections-pool-size', |
|
133 |
{'type' : 'int', |
|
134 |
'default': 4, |
|
7398
26695dd703d8
[repository api] definitly kill usage of word 'pool' to refer to connections set used by a session
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7301
diff
changeset
|
135 |
'help': 'size of the connections pool. Each source supporting multiple \ |
0 | 136 |
connections will have this number of opened connections.', |
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
137 |
'group': 'main', 'level': 3, |
0 | 138 |
}), |
139 |
('rql-cache-size', |
|
140 |
{'type' : 'int', |
|
8182
d062d3b7da6c
[config] fix rql-cache-size initial values (closes #2162160)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7896
diff
changeset
|
141 |
'default': 3000, |
0 | 142 |
'help': 'size of the parsed rql cache size.', |
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
143 |
'group': 'main', 'level': 3, |
0 | 144 |
}), |
8306
4da49700b06a
[config, undo] Fix undo-support option migration
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8265
diff
changeset
|
145 |
('undo-enabled', |
8265
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8216
diff
changeset
|
146 |
{'type' : 'yn', 'default': False, |
9747ab9230ad
[repo, undo] Finish repository-side implementation of the undo feature (closes #893940)
Anthony Truchet <anthony.truchet@logilab.fr>
parents:
8216
diff
changeset
|
147 |
'help': 'enable undo support', |
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
148 |
'group': 'main', 'level': 3, |
4913
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
4834
diff
changeset
|
149 |
}), |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
4834
diff
changeset
|
150 |
('keep-transaction-lifetime', |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
4834
diff
changeset
|
151 |
{'type' : 'int', 'default': 7, |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
4834
diff
changeset
|
152 |
'help': 'number of days during which transaction records should be \ |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
4834
diff
changeset
|
153 |
kept (hence undoable).', |
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
154 |
'group': 'main', 'level': 3, |
4913
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
4834
diff
changeset
|
155 |
}), |
5059
1d5c81588144
[repo] make etype which should go in deleted_entities configurable: we only need this for types imported from other multi-sources instances
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5043
diff
changeset
|
156 |
('multi-sources-etypes', |
1d5c81588144
[repo] make etype which should go in deleted_entities configurable: we only need this for types imported from other multi-sources instances
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5043
diff
changeset
|
157 |
{'type' : 'csv', 'default': (), |
1d5c81588144
[repo] make etype which should go in deleted_entities configurable: we only need this for types imported from other multi-sources instances
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5043
diff
changeset
|
158 |
'help': 'defines which entity types from this repository are used \ |
6128 | 159 |
by some other instances. You should set this properly for these instances to \ |
5059
1d5c81588144
[repo] make etype which should go in deleted_entities configurable: we only need this for types imported from other multi-sources instances
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5043
diff
changeset
|
160 |
detect updates / deletions.', |
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
161 |
'group': 'main', 'level': 3, |
5059
1d5c81588144
[repo] make etype which should go in deleted_entities configurable: we only need this for types imported from other multi-sources instances
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5043
diff
changeset
|
162 |
}), |
1d5c81588144
[repo] make etype which should go in deleted_entities configurable: we only need this for types imported from other multi-sources instances
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5043
diff
changeset
|
163 |
|
1160
77bf88f01fcc
new delay-full-text-indexation configuration option
sylvain.thenault@logilab.fr
parents:
136
diff
changeset
|
164 |
('delay-full-text-indexation', |
77bf88f01fcc
new delay-full-text-indexation configuration option
sylvain.thenault@logilab.fr
parents:
136
diff
changeset
|
165 |
{'type' : 'yn', 'default': False, |
77bf88f01fcc
new delay-full-text-indexation configuration option
sylvain.thenault@logilab.fr
parents:
136
diff
changeset
|
166 |
'help': 'When full text indexation of entity has a too important cost' |
77bf88f01fcc
new delay-full-text-indexation configuration option
sylvain.thenault@logilab.fr
parents:
136
diff
changeset
|
167 |
' to be done when entity are added/modified by users, activate this ' |
77bf88f01fcc
new delay-full-text-indexation configuration option
sylvain.thenault@logilab.fr
parents:
136
diff
changeset
|
168 |
'option and setup a job using cubicweb-ctl db-rebuild-fti on your ' |
77bf88f01fcc
new delay-full-text-indexation configuration option
sylvain.thenault@logilab.fr
parents:
136
diff
changeset
|
169 |
'system (using cron for instance).', |
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
170 |
'group': 'main', 'level': 3, |
1160
77bf88f01fcc
new delay-full-text-indexation configuration option
sylvain.thenault@logilab.fr
parents:
136
diff
changeset
|
171 |
}), |
1666 | 172 |
|
0 | 173 |
# email configuration |
174 |
('default-recipients-mode', |
|
175 |
{'type' : 'choice', |
|
176 |
'choices' : ('default-dest-addrs', 'users', 'none'), |
|
177 |
'default': 'default-dest-addrs', |
|
178 |
'help': 'when a notification should be sent with no specific rules \ |
|
179 |
to find recipients, recipients will be found according to this mode. Available \ |
|
180 |
modes are "default-dest-addrs" (emails specified in the configuration \ |
|
181 |
variable with the same name), "users" (every users which has activated \ |
|
182 |
account with an email set), "none" (no notification).', |
|
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
183 |
'group': 'email', 'level': 2, |
0 | 184 |
}), |
185 |
('default-dest-addrs', |
|
186 |
{'type' : 'csv', |
|
187 |
'default': (), |
|
188 |
'help': 'comma separated list of email addresses that will be used \ |
|
189 |
as default recipient when an email is sent and the notification has no \ |
|
190 |
specific recipient rules.', |
|
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
191 |
'group': 'email', 'level': 2, |
0 | 192 |
}), |
193 |
('supervising-addrs', |
|
194 |
{'type' : 'csv', |
|
195 |
'default': (), |
|
196 |
'help': 'comma separated list of email addresses that will be \ |
|
197 |
notified of every changes.', |
|
5323
329b4f6d18b4
[config] with lgc >= 0.50, option's dict inputlevel becomes level
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5059
diff
changeset
|
198 |
'group': 'email', 'level': 2, |
0 | 199 |
}), |
8669
62213a34726e
[db-api/configuration] simplify db-api and configuration so that all the connection information is in the repository url, closes #2521848
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8613
diff
changeset
|
200 |
# pyro services config |
2665
0c6281487f90
[pyro] use lgc.pyro_ext, simplify pyro related options
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2657
diff
changeset
|
201 |
('pyro-host', |
3547
0c18a6c8d9b7
fix pyro-host option type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3539
diff
changeset
|
202 |
{'type' : 'string', |
0 | 203 |
'default': None, |
2665
0c6281487f90
[pyro] use lgc.pyro_ext, simplify pyro related options
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2657
diff
changeset
|
204 |
'help': 'Pyro server host, if not detectable correctly through \ |
0c6281487f90
[pyro] use lgc.pyro_ext, simplify pyro related options
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2657
diff
changeset
|
205 |
gethostname(). It may contains port information using <host>:<port> notation, \ |
0c6281487f90
[pyro] use lgc.pyro_ext, simplify pyro related options
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2657
diff
changeset
|
206 |
and if not set, it will be choosen randomly', |
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
207 |
'group': 'pyro', 'level': 3, |
0 | 208 |
}), |
8669
62213a34726e
[db-api/configuration] simplify db-api and configuration so that all the connection information is in the repository url, closes #2521848
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8613
diff
changeset
|
209 |
('pyro-instance-id', |
62213a34726e
[db-api/configuration] simplify db-api and configuration so that all the connection information is in the repository url, closes #2521848
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8613
diff
changeset
|
210 |
{'type' : 'string', |
62213a34726e
[db-api/configuration] simplify db-api and configuration so that all the connection information is in the repository url, closes #2521848
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8613
diff
changeset
|
211 |
'default': lgconfig.Method('default_instance_id'), |
62213a34726e
[db-api/configuration] simplify db-api and configuration so that all the connection information is in the repository url, closes #2521848
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8613
diff
changeset
|
212 |
'help': 'identifier of the CubicWeb instance in the Pyro name server', |
62213a34726e
[db-api/configuration] simplify db-api and configuration so that all the connection information is in the repository url, closes #2521848
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8613
diff
changeset
|
213 |
'group': 'pyro', 'level': 1, |
62213a34726e
[db-api/configuration] simplify db-api and configuration so that all the connection information is in the repository url, closes #2521848
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8613
diff
changeset
|
214 |
}), |
62213a34726e
[db-api/configuration] simplify db-api and configuration so that all the connection information is in the repository url, closes #2521848
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8613
diff
changeset
|
215 |
('pyro-ns-host', |
62213a34726e
[db-api/configuration] simplify db-api and configuration so that all the connection information is in the repository url, closes #2521848
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8613
diff
changeset
|
216 |
{'type' : 'string', |
62213a34726e
[db-api/configuration] simplify db-api and configuration so that all the connection information is in the repository url, closes #2521848
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8613
diff
changeset
|
217 |
'default': '', |
62213a34726e
[db-api/configuration] simplify db-api and configuration so that all the connection information is in the repository url, closes #2521848
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8613
diff
changeset
|
218 |
'help': 'Pyro name server\'s host. If not set, will be detected by a \ |
62213a34726e
[db-api/configuration] simplify db-api and configuration so that all the connection information is in the repository url, closes #2521848
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8613
diff
changeset
|
219 |
broadcast query. It may contains port information using <host>:<port> notation. \ |
62213a34726e
[db-api/configuration] simplify db-api and configuration so that all the connection information is in the repository url, closes #2521848
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8613
diff
changeset
|
220 |
Use "NO_PYRONS" to create a Pyro server but not register to a pyro nameserver', |
62213a34726e
[db-api/configuration] simplify db-api and configuration so that all the connection information is in the repository url, closes #2521848
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8613
diff
changeset
|
221 |
'group': 'pyro', 'level': 1, |
62213a34726e
[db-api/configuration] simplify db-api and configuration so that all the connection information is in the repository url, closes #2521848
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8613
diff
changeset
|
222 |
}), |
62213a34726e
[db-api/configuration] simplify db-api and configuration so that all the connection information is in the repository url, closes #2521848
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8613
diff
changeset
|
223 |
('pyro-ns-group', |
62213a34726e
[db-api/configuration] simplify db-api and configuration so that all the connection information is in the repository url, closes #2521848
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8613
diff
changeset
|
224 |
{'type' : 'string', |
62213a34726e
[db-api/configuration] simplify db-api and configuration so that all the connection information is in the repository url, closes #2521848
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8613
diff
changeset
|
225 |
'default': 'cubicweb', |
62213a34726e
[db-api/configuration] simplify db-api and configuration so that all the connection information is in the repository url, closes #2521848
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8613
diff
changeset
|
226 |
'help': 'Pyro name server\'s group where the repository will be \ |
62213a34726e
[db-api/configuration] simplify db-api and configuration so that all the connection information is in the repository url, closes #2521848
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8613
diff
changeset
|
227 |
registered.', |
62213a34726e
[db-api/configuration] simplify db-api and configuration so that all the connection information is in the repository url, closes #2521848
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8613
diff
changeset
|
228 |
'group': 'pyro', 'level': 1, |
62213a34726e
[db-api/configuration] simplify db-api and configuration so that all the connection information is in the repository url, closes #2521848
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8613
diff
changeset
|
229 |
}), |
8350
e1c05bf6fdeb
[zmq] Implement a ZMQ-based Repository (closes #2290125)
David Douard <david.douard@logilab.fr>
parents:
8306
diff
changeset
|
230 |
# zmq services config |
e1c05bf6fdeb
[zmq] Implement a ZMQ-based Repository (closes #2290125)
David Douard <david.douard@logilab.fr>
parents:
8306
diff
changeset
|
231 |
('zmq-repository-address', |
e1c05bf6fdeb
[zmq] Implement a ZMQ-based Repository (closes #2290125)
David Douard <david.douard@logilab.fr>
parents:
8306
diff
changeset
|
232 |
{'type' : 'string', |
e1c05bf6fdeb
[zmq] Implement a ZMQ-based Repository (closes #2290125)
David Douard <david.douard@logilab.fr>
parents:
8306
diff
changeset
|
233 |
'default': None, |
8670
f02139297beb
prefix "tcp://" zmq uris with "zmqpickle" (closes #2574114)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8669
diff
changeset
|
234 |
'help': ('ZMQ URI on which the repository will be bound ' |
8991
5238f62a430a
[server] fix documentation of ZMQ options
Dimitri Papadopoulos <dimitri.papadopoulos@cea.fr>
parents:
8708
diff
changeset
|
235 |
'to (of the form `zmqpickle-tcp://<ipaddr>:<port>`).'), |
8350
e1c05bf6fdeb
[zmq] Implement a ZMQ-based Repository (closes #2290125)
David Douard <david.douard@logilab.fr>
parents:
8306
diff
changeset
|
236 |
'group': 'zmq', 'level': 3, |
e1c05bf6fdeb
[zmq] Implement a ZMQ-based Repository (closes #2290125)
David Douard <david.douard@logilab.fr>
parents:
8306
diff
changeset
|
237 |
}), |
8211
543e1579ba0d
[repo] Add a publish/subscribe mechanism for inter-instance communication using zmq
Julien Cristau <julien.cristau@logilab.fr>, Quentin Roquefort <quentin@kpsule.me>
parents:
7896
diff
changeset
|
238 |
('zmq-address-sub', |
543e1579ba0d
[repo] Add a publish/subscribe mechanism for inter-instance communication using zmq
Julien Cristau <julien.cristau@logilab.fr>, Quentin Roquefort <quentin@kpsule.me>
parents:
7896
diff
changeset
|
239 |
{'type' : 'csv', |
543e1579ba0d
[repo] Add a publish/subscribe mechanism for inter-instance communication using zmq
Julien Cristau <julien.cristau@logilab.fr>, Quentin Roquefort <quentin@kpsule.me>
parents:
7896
diff
changeset
|
240 |
'default' : None, |
8670
f02139297beb
prefix "tcp://" zmq uris with "zmqpickle" (closes #2574114)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8669
diff
changeset
|
241 |
'help': ('List of ZMQ addresses to subscribe to (requires pyzmq) ' |
8993
82ffa4b68c9e
[server] fix documentation of ZMQ options harder
Julien Cristau <julien.cristau@logilab.fr>
parents:
8991
diff
changeset
|
242 |
'(of the form `tcp://<ipaddr>:<port>`)'), |
8211
543e1579ba0d
[repo] Add a publish/subscribe mechanism for inter-instance communication using zmq
Julien Cristau <julien.cristau@logilab.fr>, Quentin Roquefort <quentin@kpsule.me>
parents:
7896
diff
changeset
|
243 |
'group': 'zmq', 'level': 1, |
543e1579ba0d
[repo] Add a publish/subscribe mechanism for inter-instance communication using zmq
Julien Cristau <julien.cristau@logilab.fr>, Quentin Roquefort <quentin@kpsule.me>
parents:
7896
diff
changeset
|
244 |
}), |
543e1579ba0d
[repo] Add a publish/subscribe mechanism for inter-instance communication using zmq
Julien Cristau <julien.cristau@logilab.fr>, Quentin Roquefort <quentin@kpsule.me>
parents:
7896
diff
changeset
|
245 |
('zmq-address-pub', |
543e1579ba0d
[repo] Add a publish/subscribe mechanism for inter-instance communication using zmq
Julien Cristau <julien.cristau@logilab.fr>, Quentin Roquefort <quentin@kpsule.me>
parents:
7896
diff
changeset
|
246 |
{'type' : 'string', |
543e1579ba0d
[repo] Add a publish/subscribe mechanism for inter-instance communication using zmq
Julien Cristau <julien.cristau@logilab.fr>, Quentin Roquefort <quentin@kpsule.me>
parents:
7896
diff
changeset
|
247 |
'default' : None, |
8670
f02139297beb
prefix "tcp://" zmq uris with "zmqpickle" (closes #2574114)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8669
diff
changeset
|
248 |
'help': ('ZMQ address to use for publishing (requires pyzmq) ' |
8993
82ffa4b68c9e
[server] fix documentation of ZMQ options harder
Julien Cristau <julien.cristau@logilab.fr>
parents:
8991
diff
changeset
|
249 |
'(of the form `tcp://<ipaddr>:<port>`)'), |
8211
543e1579ba0d
[repo] Add a publish/subscribe mechanism for inter-instance communication using zmq
Julien Cristau <julien.cristau@logilab.fr>, Quentin Roquefort <quentin@kpsule.me>
parents:
7896
diff
changeset
|
250 |
'group': 'zmq', 'level': 1, |
543e1579ba0d
[repo] Add a publish/subscribe mechanism for inter-instance communication using zmq
Julien Cristau <julien.cristau@logilab.fr>, Quentin Roquefort <quentin@kpsule.me>
parents:
7896
diff
changeset
|
251 |
}), |
0 | 252 |
) + CubicWebConfiguration.options) |
1666 | 253 |
|
7398
26695dd703d8
[repository api] definitly kill usage of word 'pool' to refer to connections set used by a session
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7301
diff
changeset
|
254 |
# should we init the connections pool (eg connect to sources). This is |
26695dd703d8
[repository api] definitly kill usage of word 'pool' to refer to connections set used by a session
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7301
diff
changeset
|
255 |
# usually necessary... |
26695dd703d8
[repository api] definitly kill usage of word 'pool' to refer to connections set used by a session
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7301
diff
changeset
|
256 |
init_cnxset_pool = True |
2959
daabb9bc5233
make db-restore command work even with no/corrupted database
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2730
diff
changeset
|
257 |
|
0 | 258 |
# read the schema from the database |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2107
diff
changeset
|
259 |
read_instance_schema = True |
5043
fe52dd3936cf
[repo config] cleanup read_instance_schema / bootstrap_schema / creating mess
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4913
diff
changeset
|
260 |
# set this to true to get a minimal repository, for instance to get cubes |
fe52dd3936cf
[repo config] cleanup read_instance_schema / bootstrap_schema / creating mess
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4913
diff
changeset
|
261 |
# information on commands such as i18ninstance, db-restore, etc... |
fe52dd3936cf
[repo config] cleanup read_instance_schema / bootstrap_schema / creating mess
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4913
diff
changeset
|
262 |
quick_start = False |
0 | 263 |
# check user's state at login time |
264 |
consider_user_state = True |
|
1666 | 265 |
|
0 | 266 |
# should some hooks be deactivated during [pre|post]create script execution |
267 |
free_wheel = False |
|
1666 | 268 |
|
0 | 269 |
# list of enables sources when sources restriction is necessary |
270 |
# (eg repository initialization at least) |
|
6126
aca6a2c357fd
[repository] enabled sources refactoring: to avoid error, we should always have all known source in repo.sources_by_uri and only enabled ones in repo.sources, so we still have access to the definition of temporarily disabled sources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5933
diff
changeset
|
271 |
enabled_sources = None |
1666 | 272 |
|
0 | 273 |
def bootstrap_cubes(self): |
2633
bc9386c3b2c9
get_csv is being renamed to splitstrip
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2493
diff
changeset
|
274 |
from logilab.common.textutils import splitstrip |
0 | 275 |
for line in file(join(self.apphome, 'bootstrap_cubes')): |
276 |
line = line.strip() |
|
277 |
if not line or line.startswith('#'): |
|
278 |
continue |
|
2633
bc9386c3b2c9
get_csv is being renamed to splitstrip
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2493
diff
changeset
|
279 |
self.init_cubes(self.expand_cubes(splitstrip(line))) |
0 | 280 |
break |
281 |
else: |
|
282 |
# no cubes |
|
283 |
self.init_cubes(()) |
|
1666 | 284 |
|
0 | 285 |
def write_bootstrap_cubes_file(self, cubes): |
286 |
stream = file(join(self.apphome, 'bootstrap_cubes'), 'w') |
|
287 |
stream.write('# this is a generated file only used for bootstraping\n') |
|
288 |
stream.write('# you should not have to edit this\n') |
|
289 |
stream.write('%s\n' % ','.join(cubes)) |
|
290 |
stream.close() |
|
1666 | 291 |
|
0 | 292 |
def sources_file(self): |
293 |
return join(self.apphome, 'sources') |
|
1666 | 294 |
|
0 | 295 |
# this method has to be cached since when the server is running using a |
296 |
# restricted user, this user usually don't have access to the sources |
|
297 |
# configuration file (#16102) |
|
298 |
@cached |
|
2105
92ea410806fe
refactor sources configuration, add source to sources when using a cube defining
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
299 |
def read_sources_file(self): |
9460
a2a0bc984863
[config] cleanup/refactor server sources file values handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9165
diff
changeset
|
300 |
"""return a dictionary of values found in the sources file""" |
7301
93e96700e0c0
[configuration] exit with proper message when sources file is unreadable (you usually started cw while logged with a wrong user). Closes #1631238
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7129
diff
changeset
|
301 |
return read_config(self.sources_file(), raise_if_unreadable=True) |
2105
92ea410806fe
refactor sources configuration, add source to sources when using a cube defining
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
302 |
|
9460
a2a0bc984863
[config] cleanup/refactor server sources file values handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9165
diff
changeset
|
303 |
@property |
a2a0bc984863
[config] cleanup/refactor server sources file values handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9165
diff
changeset
|
304 |
def system_source_config(self): |
a2a0bc984863
[config] cleanup/refactor server sources file values handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9165
diff
changeset
|
305 |
return self.read_sources_file()['system'] |
a2a0bc984863
[config] cleanup/refactor server sources file values handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9165
diff
changeset
|
306 |
|
a2a0bc984863
[config] cleanup/refactor server sources file values handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9165
diff
changeset
|
307 |
@property |
a2a0bc984863
[config] cleanup/refactor server sources file values handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9165
diff
changeset
|
308 |
def default_admin_config(self): |
a2a0bc984863
[config] cleanup/refactor server sources file values handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9165
diff
changeset
|
309 |
return self.read_sources_file()['admin'] |
6126
aca6a2c357fd
[repository] enabled sources refactoring: to avoid error, we should always have all known source in repo.sources_by_uri and only enabled ones in repo.sources, so we still have access to the definition of temporarily disabled sources
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5933
diff
changeset
|
310 |
|
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
311 |
def source_enabled(self, source): |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
312 |
if self.sources_mode is not None: |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
313 |
if 'migration' in self.sources_mode: |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
314 |
assert len(self.sources_mode) == 1 |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
315 |
if source.connect_for_migration: |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
316 |
return True |
6478
8098e1295cf0
[server] fix dumb name error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6427
diff
changeset
|
317 |
print 'not connecting to source', source.uri, 'during migration' |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
318 |
return False |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
319 |
if 'all' in self.sources_mode: |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
320 |
assert len(self.sources_mode) == 1 |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
321 |
return True |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
322 |
return source.uri in self.sources_mode |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
323 |
if self.quick_start: |
8613
9d792e9f1c79
[server config] on quick start, system source is still activated. Closes #2535714
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
8350
diff
changeset
|
324 |
return source.uri == 'system' |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
325 |
return (not source.disabled and ( |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
326 |
not self.enabled_sources or source.uri in self.enabled_sources)) |
1666 | 327 |
|
2105
92ea410806fe
refactor sources configuration, add source to sources when using a cube defining
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
328 |
def write_sources_file(self, sourcescfg): |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
329 |
"""serialize repository'sources configuration into a INI like file""" |
2105
92ea410806fe
refactor sources configuration, add source to sources when using a cube defining
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
330 |
sourcesfile = self.sources_file() |
2107
6c4a4c514ac2
add source to sources configuration when adding a cube defining a source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2105
diff
changeset
|
331 |
if exists(sourcesfile): |
6c4a4c514ac2
add source to sources configuration when adding a cube defining a source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2105
diff
changeset
|
332 |
import shutil |
6c4a4c514ac2
add source to sources configuration when adding a cube defining a source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2105
diff
changeset
|
333 |
shutil.copy(sourcesfile, sourcesfile + '.bak') |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
334 |
stream = open(sourcesfile, 'w') |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
335 |
for section in ('admin', 'system'): |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
336 |
sconfig = sourcescfg[section] |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
337 |
if isinstance(sconfig, dict): |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
338 |
# get a Configuration object |
8988
6cd912702239
[server] fix error messages in write_sources_file()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
8708
diff
changeset
|
339 |
assert section == 'system', '%r is not system' % section |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
340 |
_sconfig = SourceConfiguration( |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
341 |
self, options=SOURCE_TYPES['native'].options) |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
342 |
for attr, val in sconfig.items(): |
6670
e22bd5eb6ffd
[c-c reset-admin-pwd] don't crash on unknown option, and silently ignore 'adapter' which may be present in pre 3.10 sources file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6627
diff
changeset
|
343 |
try: |
e22bd5eb6ffd
[c-c reset-admin-pwd] don't crash on unknown option, and silently ignore 'adapter' which may be present in pre 3.10 sources file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6627
diff
changeset
|
344 |
_sconfig.set_option(attr, val) |
e22bd5eb6ffd
[c-c reset-admin-pwd] don't crash on unknown option, and silently ignore 'adapter' which may be present in pre 3.10 sources file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6627
diff
changeset
|
345 |
except lgconfig.OptionError: |
e22bd5eb6ffd
[c-c reset-admin-pwd] don't crash on unknown option, and silently ignore 'adapter' which may be present in pre 3.10 sources file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6627
diff
changeset
|
346 |
# skip adapter, may be present on pre 3.10 instances |
e22bd5eb6ffd
[c-c reset-admin-pwd] don't crash on unknown option, and silently ignore 'adapter' which may be present in pre 3.10 sources file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6627
diff
changeset
|
347 |
if attr != 'adapter': |
8988
6cd912702239
[server] fix error messages in write_sources_file()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
8708
diff
changeset
|
348 |
self.error('skip unknown option %s in sources file' % attr) |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
349 |
sconfig = _sconfig |
7896
4c954e1e73ef
[lint] remove uses of "print >> sys.stderr" (closes #1908571)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
7398
diff
changeset
|
350 |
stream.write('[%s]\n%s\n' % (section, generate_source_config(sconfig))) |
2105
92ea410806fe
refactor sources configuration, add source to sources when using a cube defining
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
351 |
restrict_perms_to_user(sourcesfile) |
92ea410806fe
refactor sources configuration, add source to sources when using a cube defining
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
352 |
|
0 | 353 |
def pyro_enabled(self): |
354 |
"""pyro is always enabled in standalone repository configuration""" |
|
355 |
return True |
|
1666 | 356 |
|
357 |
def load_schema(self, expand_cubes=False, **kwargs): |
|
0 | 358 |
from cubicweb.schema import CubicWebSchemaLoader |
359 |
if expand_cubes: |
|
360 |
# in case some new dependencies have been introduced, we have to |
|
361 |
# reinitialize cubes so the full filesystem schema is read |
|
362 |
origcubes = self.cubes() |
|
363 |
self._cubes = None |
|
364 |
self.init_cubes(self.expand_cubes(origcubes)) |
|
1666 | 365 |
schema = CubicWebSchemaLoader().load(self, **kwargs) |
0 | 366 |
if expand_cubes: |
9165
7ebf3b1cdb4c
Use the list of cubes from the filesystem when reading the schema from the filesystem
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
9013
diff
changeset
|
367 |
# restore original value |
0 | 368 |
self._cubes = origcubes |
369 |
return schema |
|
1666 | 370 |
|
0 | 371 |
def load_bootstrap_schema(self): |
372 |
from cubicweb.schema import BootstrapSchemaLoader |
|
373 |
schema = BootstrapSchemaLoader().load(self) |
|
374 |
schema.name = 'bootstrap' |
|
375 |
return schema |
|
1666 | 376 |
|
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
377 |
sources_mode = None |
0 | 378 |
def set_sources_mode(self, sources): |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
379 |
self.sources_mode = sources |
1666 | 380 |
|
0 | 381 |
def migration_handler(self, schema=None, interactive=True, |
2493
9806571ea790
major refactoring of database dump/restore:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2489
diff
changeset
|
382 |
cnx=None, repo=None, connect=True, verbosity=None): |
0 | 383 |
"""return a migration handler instance""" |
384 |
from cubicweb.server.migractions import ServerMigrationHelper |
|
2493
9806571ea790
major refactoring of database dump/restore:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2489
diff
changeset
|
385 |
if verbosity is None: |
9806571ea790
major refactoring of database dump/restore:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2489
diff
changeset
|
386 |
verbosity = getattr(self, 'verbosity', 0) |
0 | 387 |
return ServerMigrationHelper(self, schema, interactive=interactive, |
388 |
cnx=cnx, repo=repo, connect=connect, |
|
2493
9806571ea790
major refactoring of database dump/restore:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2489
diff
changeset
|
389 |
verbosity=verbosity) |
6844
5ae2bc554c23
[config] stop using a metaclass for registration of "public" configuration, simply do it explicitly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6670
diff
changeset
|
390 |
|
5ae2bc554c23
[config] stop using a metaclass for registration of "public" configuration, simply do it explicitly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6670
diff
changeset
|
391 |
|
5ae2bc554c23
[config] stop using a metaclass for registration of "public" configuration, simply do it explicitly
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6670
diff
changeset
|
392 |
CONFIGURATIONS.append(ServerConfiguration) |