author | Julien Cristau <julien.cristau@logilab.fr> |
Tue, 23 Jun 2015 17:04:40 +0200 | |
changeset 10495 | 5bd914ebf3ae |
parent 10301 | 729f36a1bcfa |
child 10589 | 7c23b7de2b8d |
permissions | -rw-r--r-- |
10235
684215aca046
Remove remote repository-access-through-pyro support
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9468
diff
changeset
|
1 |
# copyright 2003-2014 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 |
}), |
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
|
200 |
('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
|
201 |
{'type' : 'csv', |
10233
f7dfcb3add15
[server] Make sure 'zmq-address-sub' config is always iterable
Rémi Cardona <remi.cardona@logilab.fr>
parents:
9468
diff
changeset
|
202 |
'default' : (), |
8670
f02139297beb
prefix "tcp://" zmq uris with "zmqpickle" (closes #2574114)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8669
diff
changeset
|
203 |
'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
|
204 |
'(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
|
205 |
'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
|
206 |
}), |
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
|
207 |
('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
|
208 |
{'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
|
209 |
'default' : None, |
8670
f02139297beb
prefix "tcp://" zmq uris with "zmqpickle" (closes #2574114)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8669
diff
changeset
|
210 |
'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
|
211 |
'(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
|
212 |
'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
|
213 |
}), |
0 | 214 |
) + CubicWebConfiguration.options) |
1666 | 215 |
|
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
|
216 |
# 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
|
217 |
# 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
|
218 |
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
|
219 |
|
0 | 220 |
# 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
|
221 |
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
|
222 |
# 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
|
223 |
# 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
|
224 |
quick_start = False |
0 | 225 |
# check user's state at login time |
226 |
consider_user_state = True |
|
1666 | 227 |
|
0 | 228 |
# should some hooks be deactivated during [pre|post]create script execution |
229 |
free_wheel = False |
|
1666 | 230 |
|
0 | 231 |
# list of enables sources when sources restriction is necessary |
232 |
# (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
|
233 |
enabled_sources = None |
1666 | 234 |
|
0 | 235 |
def bootstrap_cubes(self): |
2633
bc9386c3b2c9
get_csv is being renamed to splitstrip
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2493
diff
changeset
|
236 |
from logilab.common.textutils import splitstrip |
0 | 237 |
for line in file(join(self.apphome, 'bootstrap_cubes')): |
238 |
line = line.strip() |
|
239 |
if not line or line.startswith('#'): |
|
240 |
continue |
|
2633
bc9386c3b2c9
get_csv is being renamed to splitstrip
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2493
diff
changeset
|
241 |
self.init_cubes(self.expand_cubes(splitstrip(line))) |
0 | 242 |
break |
243 |
else: |
|
244 |
# no cubes |
|
245 |
self.init_cubes(()) |
|
1666 | 246 |
|
0 | 247 |
def write_bootstrap_cubes_file(self, cubes): |
248 |
stream = file(join(self.apphome, 'bootstrap_cubes'), 'w') |
|
249 |
stream.write('# this is a generated file only used for bootstraping\n') |
|
250 |
stream.write('# you should not have to edit this\n') |
|
251 |
stream.write('%s\n' % ','.join(cubes)) |
|
252 |
stream.close() |
|
1666 | 253 |
|
0 | 254 |
def sources_file(self): |
255 |
return join(self.apphome, 'sources') |
|
1666 | 256 |
|
0 | 257 |
# this method has to be cached since when the server is running using a |
258 |
# restricted user, this user usually don't have access to the sources |
|
259 |
# configuration file (#16102) |
|
260 |
@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
|
261 |
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
|
262 |
"""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
|
263 |
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
|
264 |
|
9460
a2a0bc984863
[config] cleanup/refactor server sources file values handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9165
diff
changeset
|
265 |
@property |
a2a0bc984863
[config] cleanup/refactor server sources file values handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9165
diff
changeset
|
266 |
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
|
267 |
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
|
268 |
|
a2a0bc984863
[config] cleanup/refactor server sources file values handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9165
diff
changeset
|
269 |
@property |
a2a0bc984863
[config] cleanup/refactor server sources file values handling
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
9165
diff
changeset
|
270 |
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
|
271 |
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
|
272 |
|
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
273 |
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
|
274 |
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
|
275 |
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
|
276 |
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
|
277 |
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
|
278 |
return True |
6478
8098e1295cf0
[server] fix dumb name error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6427
diff
changeset
|
279 |
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
|
280 |
return False |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
281 |
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
|
282 |
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
|
283 |
return True |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
284 |
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
|
285 |
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
|
286 |
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
|
287 |
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
|
288 |
not self.enabled_sources or source.uri in self.enabled_sources)) |
1666 | 289 |
|
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
|
290 |
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
|
291 |
"""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
|
292 |
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
|
293 |
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
|
294 |
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
|
295 |
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
|
296 |
stream = open(sourcesfile, 'w') |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
297 |
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
|
298 |
sconfig = sourcescfg[section] |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
299 |
if isinstance(sconfig, dict): |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
300 |
# get a Configuration object |
8988
6cd912702239
[server] fix error messages in write_sources_file()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
8708
diff
changeset
|
301 |
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
|
302 |
_sconfig = SourceConfiguration( |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
303 |
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
|
304 |
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
|
305 |
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
|
306 |
_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
|
307 |
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
|
308 |
# 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
|
309 |
if attr != 'adapter': |
8988
6cd912702239
[server] fix error messages in write_sources_file()
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
8708
diff
changeset
|
310 |
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
|
311 |
sconfig = _sconfig |
7896
4c954e1e73ef
[lint] remove uses of "print >> sys.stderr" (closes #1908571)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
7398
diff
changeset
|
312 |
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
|
313 |
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
|
314 |
|
1666 | 315 |
def load_schema(self, expand_cubes=False, **kwargs): |
0 | 316 |
from cubicweb.schema import CubicWebSchemaLoader |
317 |
if expand_cubes: |
|
318 |
# in case some new dependencies have been introduced, we have to |
|
319 |
# reinitialize cubes so the full filesystem schema is read |
|
320 |
origcubes = self.cubes() |
|
321 |
self._cubes = None |
|
322 |
self.init_cubes(self.expand_cubes(origcubes)) |
|
1666 | 323 |
schema = CubicWebSchemaLoader().load(self, **kwargs) |
0 | 324 |
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
|
325 |
# restore original value |
0 | 326 |
self._cubes = origcubes |
327 |
return schema |
|
1666 | 328 |
|
0 | 329 |
def load_bootstrap_schema(self): |
330 |
from cubicweb.schema import BootstrapSchemaLoader |
|
331 |
schema = BootstrapSchemaLoader().load(self) |
|
332 |
schema.name = 'bootstrap' |
|
333 |
return schema |
|
1666 | 334 |
|
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
335 |
sources_mode = None |
0 | 336 |
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
|
337 |
self.sources_mode = sources |
1666 | 338 |
|
0 | 339 |
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
|
340 |
cnx=None, repo=None, connect=True, verbosity=None): |
0 | 341 |
"""return a migration handler instance""" |
342 |
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
|
343 |
if verbosity is None: |
9806571ea790
major refactoring of database dump/restore:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2489
diff
changeset
|
344 |
verbosity = getattr(self, 'verbosity', 0) |
0 | 345 |
return ServerMigrationHelper(self, schema, interactive=interactive, |
346 |
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
|
347 |
verbosity=verbosity) |