author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Thu, 01 Mar 2012 13:39:43 +0100 | |
branch | stable |
changeset 8285 | 32098d98bf2f |
parent 8182 | d062d3b7da6c |
child 8216 | 99ff746e8de8 |
permissions | -rw-r--r-- |
7129
455b503fb7ff
[config] generalise config.creating, allowing to drop set_language class attribute
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6844
diff
changeset
|
1 |
# copyright 2003-2011 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 |
6128 | 27 |
from logilab.common.decorators import wproperty, cached |
0 | 28 |
|
3637 | 29 |
from cubicweb.toolsutils import read_config, restrict_perms_to_user |
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
|
30 |
from cubicweb.cwconfig import CONFIGURATIONS, CubicWebConfiguration, merge_options |
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()) |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
85 |
assert len(optsbysect) == 1, 'all options for a source should be in the same group' |
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
|
86 |
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
|
87 |
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
|
88 |
|
92ea410806fe
refactor sources configuration, add source to sources when using a cube defining
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
89 |
|
0 | 90 |
class ServerConfiguration(CubicWebConfiguration): |
91 |
"""standalone RQL server""" |
|
92 |
name = 'repository' |
|
93 |
||
2835
04034421b072
[hooks] major refactoring:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2810
diff
changeset
|
94 |
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
|
95 |
cube_appobject_path = CubicWebConfiguration.cube_appobject_path | set(['sobjects', 'hooks']) |
0 | 96 |
|
97 |
options = merge_options(( |
|
98 |
# ctl configuration |
|
99 |
('host', |
|
100 |
{'type' : 'string', |
|
101 |
'default': None, |
|
102 |
'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
|
103 |
'group': 'main', 'level': 1, |
0 | 104 |
}), |
105 |
('pid-file', |
|
106 |
{'type' : 'string', |
|
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
107 |
'default': lgconfig.Method('default_pid_file'), |
0 | 108 |
'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
|
109 |
'group': 'main', 'level': 2, |
0 | 110 |
}), |
111 |
('uid', |
|
112 |
{'type' : 'string', |
|
113 |
'default': None, |
|
114 |
'help': 'if this option is set, use the specified user to start \ |
|
115 |
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
|
116 |
'group': 'main', 'level': (CubicWebConfiguration.mode == 'installed') and 0 or 1, |
0 | 117 |
}), |
6012
d56fd78006cd
[session] cleanup session-time / cleanup-session-time...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5933
diff
changeset
|
118 |
('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
|
119 |
{'type' : 'time', |
6012
d56fd78006cd
[session] cleanup session-time / cleanup-session-time...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5933
diff
changeset
|
120 |
'default': '24h', |
d56fd78006cd
[session] cleanup session-time / cleanup-session-time...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5933
diff
changeset
|
121 |
'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
|
122 |
'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
|
123 |
'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
|
124 |
'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
|
125 |
'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
|
126 |
'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
|
127 |
'of inactivity. Default to 24h.', |
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
128 |
'group': 'main', 'level': 3, |
0 | 129 |
}), |
130 |
('connections-pool-size', |
|
131 |
{'type' : 'int', |
|
132 |
'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
|
133 |
'help': 'size of the connections pool. Each source supporting multiple \ |
0 | 134 |
connections will have this number of opened connections.', |
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
135 |
'group': 'main', 'level': 3, |
0 | 136 |
}), |
137 |
('rql-cache-size', |
|
138 |
{'type' : 'int', |
|
8182
d062d3b7da6c
[config] fix rql-cache-size initial values (closes #2162160)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7896
diff
changeset
|
139 |
'default': 3000, |
0 | 140 |
'help': 'size of the parsed rql cache size.', |
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
141 |
'group': 'main', 'level': 3, |
0 | 142 |
}), |
4913
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
4834
diff
changeset
|
143 |
('undo-support', |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
4834
diff
changeset
|
144 |
{'type' : 'string', 'default': '', |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
4834
diff
changeset
|
145 |
'help': 'string defining actions that will have undo support: \ |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
4834
diff
changeset
|
146 |
[C]reate [U]pdate [D]elete entities / [A]dd [R]emove relation. Leave it empty \ |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
4834
diff
changeset
|
147 |
for no undo support, set it to CUDAR for full undo support, or to DR for \ |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
4834
diff
changeset
|
148 |
support undoing of deletion only.', |
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
149 |
'group': 'main', 'level': 3, |
4913
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
4834
diff
changeset
|
150 |
}), |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
4834
diff
changeset
|
151 |
('keep-transaction-lifetime', |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
4834
diff
changeset
|
152 |
{'type' : 'int', 'default': 7, |
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
4834
diff
changeset
|
153 |
'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
|
154 |
kept (hence undoable).', |
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
155 |
'group': 'main', 'level': 3, |
4913
083b4d454192
server/web api for accessing to deleted_entites
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents:
4834
diff
changeset
|
156 |
}), |
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
|
157 |
('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
|
158 |
{'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
|
159 |
'help': 'defines which entity types from this repository are used \ |
6128 | 160 |
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
|
161 |
detect updates / deletions.', |
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
162 |
'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
|
163 |
}), |
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
|
164 |
|
1160
77bf88f01fcc
new delay-full-text-indexation configuration option
sylvain.thenault@logilab.fr
parents:
136
diff
changeset
|
165 |
('delay-full-text-indexation', |
77bf88f01fcc
new delay-full-text-indexation configuration option
sylvain.thenault@logilab.fr
parents:
136
diff
changeset
|
166 |
{'type' : 'yn', 'default': False, |
77bf88f01fcc
new delay-full-text-indexation configuration option
sylvain.thenault@logilab.fr
parents:
136
diff
changeset
|
167 |
'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
|
168 |
' 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
|
169 |
'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
|
170 |
'system (using cron for instance).', |
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
171 |
'group': 'main', 'level': 3, |
1160
77bf88f01fcc
new delay-full-text-indexation configuration option
sylvain.thenault@logilab.fr
parents:
136
diff
changeset
|
172 |
}), |
1666 | 173 |
|
0 | 174 |
# email configuration |
175 |
('default-recipients-mode', |
|
176 |
{'type' : 'choice', |
|
177 |
'choices' : ('default-dest-addrs', 'users', 'none'), |
|
178 |
'default': 'default-dest-addrs', |
|
179 |
'help': 'when a notification should be sent with no specific rules \ |
|
180 |
to find recipients, recipients will be found according to this mode. Available \ |
|
181 |
modes are "default-dest-addrs" (emails specified in the configuration \ |
|
182 |
variable with the same name), "users" (every users which has activated \ |
|
183 |
account with an email set), "none" (no notification).', |
|
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
184 |
'group': 'email', 'level': 2, |
0 | 185 |
}), |
186 |
('default-dest-addrs', |
|
187 |
{'type' : 'csv', |
|
188 |
'default': (), |
|
189 |
'help': 'comma separated list of email addresses that will be used \ |
|
190 |
as default recipient when an email is sent and the notification has no \ |
|
191 |
specific recipient rules.', |
|
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
192 |
'group': 'email', 'level': 2, |
0 | 193 |
}), |
194 |
('supervising-addrs', |
|
195 |
{'type' : 'csv', |
|
196 |
'default': (), |
|
197 |
'help': 'comma separated list of email addresses that will be \ |
|
198 |
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
|
199 |
'group': 'email', 'level': 2, |
0 | 200 |
}), |
201 |
# pyro server.serverconfig |
|
2665
0c6281487f90
[pyro] use lgc.pyro_ext, simplify pyro related options
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2657
diff
changeset
|
202 |
('pyro-host', |
3547
0c18a6c8d9b7
fix pyro-host option type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3539
diff
changeset
|
203 |
{'type' : 'string', |
0 | 204 |
'default': None, |
2665
0c6281487f90
[pyro] use lgc.pyro_ext, simplify pyro related options
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2657
diff
changeset
|
205 |
'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
|
206 |
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
|
207 |
and if not set, it will be choosen randomly', |
5456
d040889fac4e
merged back oldstable into stable
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
diff
changeset
|
208 |
'group': 'pyro', 'level': 3, |
0 | 209 |
}), |
210 |
) + CubicWebConfiguration.options) |
|
1666 | 211 |
|
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
|
212 |
# 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
|
213 |
# 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
|
214 |
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
|
215 |
|
0 | 216 |
# 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
|
217 |
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
|
218 |
# 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
|
219 |
# 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
|
220 |
quick_start = False |
0 | 221 |
# check user's state at login time |
222 |
consider_user_state = True |
|
1666 | 223 |
|
0 | 224 |
# should some hooks be deactivated during [pre|post]create script execution |
225 |
free_wheel = False |
|
1666 | 226 |
|
0 | 227 |
# list of enables sources when sources restriction is necessary |
228 |
# (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
|
229 |
enabled_sources = None |
1666 | 230 |
|
0 | 231 |
def bootstrap_cubes(self): |
2633
bc9386c3b2c9
get_csv is being renamed to splitstrip
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2493
diff
changeset
|
232 |
from logilab.common.textutils import splitstrip |
0 | 233 |
for line in file(join(self.apphome, 'bootstrap_cubes')): |
234 |
line = line.strip() |
|
235 |
if not line or line.startswith('#'): |
|
236 |
continue |
|
2633
bc9386c3b2c9
get_csv is being renamed to splitstrip
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2493
diff
changeset
|
237 |
self.init_cubes(self.expand_cubes(splitstrip(line))) |
0 | 238 |
break |
239 |
else: |
|
240 |
# no cubes |
|
241 |
self.init_cubes(()) |
|
1666 | 242 |
|
0 | 243 |
def write_bootstrap_cubes_file(self, cubes): |
244 |
stream = file(join(self.apphome, 'bootstrap_cubes'), 'w') |
|
245 |
stream.write('# this is a generated file only used for bootstraping\n') |
|
246 |
stream.write('# you should not have to edit this\n') |
|
247 |
stream.write('%s\n' % ','.join(cubes)) |
|
248 |
stream.close() |
|
1666 | 249 |
|
0 | 250 |
def sources_file(self): |
251 |
return join(self.apphome, 'sources') |
|
1666 | 252 |
|
0 | 253 |
# this method has to be cached since when the server is running using a |
254 |
# restricted user, this user usually don't have access to the sources |
|
255 |
# configuration file (#16102) |
|
256 |
@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
|
257 |
def read_sources_file(self): |
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
|
258 |
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
|
259 |
|
0 | 260 |
def sources(self): |
261 |
"""return a dictionnaries containing sources definitions indexed by |
|
262 |
sources'uri |
|
263 |
""" |
|
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
|
264 |
return self.read_sources_file() |
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
|
265 |
|
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
266 |
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
|
267 |
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
|
268 |
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
|
269 |
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
|
270 |
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
|
271 |
return True |
6478
8098e1295cf0
[server] fix dumb name error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6427
diff
changeset
|
272 |
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
|
273 |
return False |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
274 |
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
|
275 |
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
|
276 |
return True |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
277 |
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
|
278 |
if self.quick_start: |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
279 |
return False |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
280 |
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
|
281 |
not self.enabled_sources or source.uri in self.enabled_sources)) |
1666 | 282 |
|
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
|
283 |
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
|
284 |
"""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
|
285 |
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
|
286 |
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
|
287 |
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
|
288 |
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
|
289 |
stream = open(sourcesfile, 'w') |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
290 |
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
|
291 |
sconfig = sourcescfg[section] |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
292 |
if isinstance(sconfig, dict): |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
293 |
# get a Configuration object |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
294 |
assert section == 'system' |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
295 |
_sconfig = SourceConfiguration( |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
296 |
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
|
297 |
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
|
298 |
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
|
299 |
_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
|
300 |
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
|
301 |
# 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
|
302 |
if attr != 'adapter': |
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
|
303 |
self.error('skip unknown option %s in sources file') |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
304 |
sconfig = _sconfig |
7896
4c954e1e73ef
[lint] remove uses of "print >> sys.stderr" (closes #1908571)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
7398
diff
changeset
|
305 |
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
|
306 |
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
|
307 |
|
0 | 308 |
def pyro_enabled(self): |
309 |
"""pyro is always enabled in standalone repository configuration""" |
|
310 |
return True |
|
1666 | 311 |
|
312 |
def load_schema(self, expand_cubes=False, **kwargs): |
|
0 | 313 |
from cubicweb.schema import CubicWebSchemaLoader |
314 |
if expand_cubes: |
|
315 |
# in case some new dependencies have been introduced, we have to |
|
316 |
# reinitialize cubes so the full filesystem schema is read |
|
317 |
origcubes = self.cubes() |
|
318 |
self._cubes = None |
|
319 |
self.init_cubes(self.expand_cubes(origcubes)) |
|
1666 | 320 |
schema = CubicWebSchemaLoader().load(self, **kwargs) |
0 | 321 |
if expand_cubes: |
322 |
# restaure original value |
|
323 |
self._cubes = origcubes |
|
324 |
return schema |
|
1666 | 325 |
|
0 | 326 |
def load_bootstrap_schema(self): |
327 |
from cubicweb.schema import BootstrapSchemaLoader |
|
328 |
schema = BootstrapSchemaLoader().load(self) |
|
329 |
schema.name = 'bootstrap' |
|
330 |
return schema |
|
1666 | 331 |
|
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6333
diff
changeset
|
332 |
sources_mode = None |
0 | 333 |
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
|
334 |
self.sources_mode = sources |
1666 | 335 |
|
0 | 336 |
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
|
337 |
cnx=None, repo=None, connect=True, verbosity=None): |
0 | 338 |
"""return a migration handler instance""" |
339 |
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
|
340 |
if verbosity is None: |
9806571ea790
major refactoring of database dump/restore:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2489
diff
changeset
|
341 |
verbosity = getattr(self, 'verbosity', 0) |
0 | 342 |
return ServerMigrationHelper(self, schema, interactive=interactive, |
343 |
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
|
344 |
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
|
345 |
|
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
|
346 |
|
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
|
347 |
CONFIGURATIONS.append(ServerConfiguration) |