author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Wed, 25 Aug 2010 19:09:18 +0200 | |
changeset 6151 | f910c60b84ff |
parent 5515 | 513af9be9e37 |
permissions | -rw-r--r-- |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5043
diff
changeset
|
1 |
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5043
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:
5043
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:
5043
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:
5043
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:
5043
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:
5043
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:
5043
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:
5043
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:
5043
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:
5043
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:
5043
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:
5043
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:
5043
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:
5043
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:
5043
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
0 | 18 |
"""google appengine configuration |
19 |
||
20 |
""" |
|
21 |
__docformat__ = "restructuredtext en" |
|
22 |
||
23 |
import os |
|
24 |
from os.path import join |
|
25 |
||
26 |
from cubicweb import CW_SOFTWARE_ROOT |
|
27 |
from cubicweb.cwconfig import CubicWebConfiguration |
|
1132 | 28 |
from cubicweb.web.webconfig import WebConfiguration, merge_options |
0 | 29 |
from cubicweb.server.serverconfig import ServerConfiguration |
30 |
from cubicweb.goa.dbmyams import load_schema |
|
31 |
||
32 |
UNSUPPORTED_OPTIONS = set(('connections-pool-size', |
|
3539
f3b14d052798
[pyro] merge pyro-id / pyro-instance-id options, put all pyro options in the same section of the configuration file
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2665
diff
changeset
|
33 |
'pyro-host', 'pyro-instance-id', |
2665
0c6281487f90
[pyro] use lgc.pyro_ext, simplify pyro related options
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2657
diff
changeset
|
34 |
'pyro-ns-host', 'pyro-ns-group', |
0 | 35 |
'https-url', 'host', 'pid-file', 'uid', 'base-url', 'log-file', |
36 |
'smtp-host', 'smtp-port', |
|
37 |
'embed-allowed', |
|
38 |
)) |
|
39 |
||
40 |
# XXX fix: |
|
41 |
# * default sender-name / sender-addr value |
|
42 |
# * what about *session-time |
|
43 |
# * check auth-mode=http + fix doc (eg require use-google-auth = False) |
|
44 |
||
45 |
class GAEConfiguration(ServerConfiguration, WebConfiguration): |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
46 |
"""repository and web instance in Google AppEngine environment""" |
0 | 47 |
name = 'app' |
48 |
repo_method = 'inmemory' |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1132
diff
changeset
|
49 |
options = merge_options(( |
0 | 50 |
('included-cubes', |
51 |
{'type' : 'csv', |
|
52 |
'default': [], |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
53 |
'help': 'list of db model based cubes used by the instance.', |
5515
513af9be9e37
[config] rename remaining inputlevel to level in option definitions, as expected by lgc >= 0.50
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
54 |
'group': 'main', 'level': 1, |
0 | 55 |
}), |
56 |
('included-yams-cubes', |
|
57 |
{'type' : 'csv', |
|
58 |
'default': [], |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
59 |
'help': 'list of yams based cubes used by the instance.', |
5515
513af9be9e37
[config] rename remaining inputlevel to level in option definitions, as expected by lgc >= 0.50
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
60 |
'group': 'main', 'level': 1, |
0 | 61 |
}), |
62 |
('use-google-auth', |
|
63 |
{'type' : 'yn', |
|
64 |
'default': True, |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
65 |
'help': 'does this instance rely on google authentication service or not.', |
5515
513af9be9e37
[config] rename remaining inputlevel to level in option definitions, as expected by lgc >= 0.50
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
66 |
'group': 'main', 'level': 1, |
0 | 67 |
}), |
68 |
('schema-type', |
|
69 |
{'type' : 'choice', 'choices': ('yams', 'dbmodel'), |
|
70 |
'default': 'yams', |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
71 |
'help': 'does this instance is defining its schema using yams or db model.', |
5515
513af9be9e37
[config] rename remaining inputlevel to level in option definitions, as expected by lgc >= 0.50
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
72 |
'group': 'main', 'level': 1, |
0 | 73 |
}), |
74 |
# overriden options |
|
75 |
('query-log-file', |
|
76 |
{'type' : 'string', |
|
77 |
'default': None, |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
78 |
'help': 'web instance query log file: DON\'T SET A VALUE HERE WHEN ' |
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
79 |
'UPLOADING YOUR INSTANCE. This should only be used to analyse ' |
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
80 |
'queries issued by your instance in the development environment.', |
5515
513af9be9e37
[config] rename remaining inputlevel to level in option definitions, as expected by lgc >= 0.50
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
81 |
'group': 'main', 'level': 2, |
0 | 82 |
}), |
83 |
('anonymous-user', |
|
84 |
{'type' : 'string', |
|
85 |
'default': None, |
|
86 |
'help': 'login of the CubicWeb user account to use for anonymous user ' |
|
87 |
'(if you want to allow anonymous). This option will be ignored if ' |
|
88 |
'use-google-auth option is set (in which case you should control ' |
|
89 |
'anonymous access using the app.yaml file)', |
|
5515
513af9be9e37
[config] rename remaining inputlevel to level in option definitions, as expected by lgc >= 0.50
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5424
diff
changeset
|
90 |
'group': 'main', 'level': 1, |
0 | 91 |
}), |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1132
diff
changeset
|
92 |
|
0 | 93 |
) + WebConfiguration.options + ServerConfiguration.options) |
94 |
options = [(optname, optdict) for optname, optdict in options |
|
95 |
if not optname in UNSUPPORTED_OPTIONS] |
|
96 |
||
2657
de974465d381
[appobject] kill VObject class, move base selector classes to appobject
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2476
diff
changeset
|
97 |
cubicweb_appobject_path = WebConfiguration.cubicweb_appobject_path | ServerConfiguration.cubicweb_appobject_path |
de974465d381
[appobject] kill VObject class, move base selector classes to appobject
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2476
diff
changeset
|
98 |
cubicweb_appobject_path = list(cubicweb_appobject_path) + ['goa/appobjects'] |
de974465d381
[appobject] kill VObject class, move base selector classes to appobject
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2476
diff
changeset
|
99 |
cube_appobject_path = WebConfiguration.cube_appobject_path | ServerConfiguration.cube_appobject_path |
0 | 100 |
|
101 |
# use file system schema |
|
5043
fe52dd3936cf
[repo config] cleanup read_instance_schema / bootstrap_schema / creating mess
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4212
diff
changeset
|
102 |
read_instance_schema = False |
0 | 103 |
# schema is not persistent, don't load schema hooks (unavailable) |
104 |
schema_hooks = False |
|
105 |
# no user workflow for now |
|
106 |
consider_user_state = False |
|
107 |
||
108 |
# deactivate some hooks during [pre|post]create scripts execution |
|
109 |
# (unique values check, owned_by/created_by relations setup) |
|
110 |
free_wheel = True |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1132
diff
changeset
|
111 |
|
0 | 112 |
if not os.environ.get('APYCOT_ROOT'): |
113 |
CUBES_DIR = join(CW_SOFTWARE_ROOT, '../cubes') |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1132
diff
changeset
|
114 |
|
0 | 115 |
def __init__(self, appid, apphome=None): |
116 |
if apphome is None: |
|
117 |
apphome = 'data' |
|
118 |
self._apphome = apphome |
|
119 |
self._base_url = None |
|
120 |
CubicWebConfiguration.__init__(self, appid) |
|
121 |
||
122 |
def __getitem__(self, key): |
|
123 |
if key == 'connections-pool-size': |
|
124 |
return 4 # > 1 to allow multiple user sessions in tests |
|
125 |
if key == 'base-url': |
|
126 |
return self._base_url |
|
127 |
return super(GAEConfiguration, self).__getitem__(key) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1132
diff
changeset
|
128 |
|
0 | 129 |
# overriden from cubicweb base configuration |
130 |
||
131 |
@property |
|
132 |
def apphome(self): |
|
133 |
return self._apphome |
|
134 |
||
135 |
def cubes(self): |
|
136 |
"""return the list of top level cubes used by this instance (eg |
|
137 |
without dependencies) |
|
138 |
""" |
|
139 |
if self._cubes is None: |
|
140 |
cubes = self['included-cubes'] + self['included-yams-cubes'] |
|
141 |
cubes = self.expand_cubes(cubes) |
|
142 |
return self.reorder_cubes(cubes) |
|
143 |
return self._cubes |
|
144 |
||
145 |
def vc_config(self): |
|
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
146 |
"""return CubicWeb's engine and instance's cube versions number""" |
0 | 147 |
return {} |
148 |
||
149 |
# overriden from cubicweb web configuration |
|
150 |
||
151 |
def instance_md5_version(self): |
|
152 |
return '' |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1132
diff
changeset
|
153 |
|
0 | 154 |
def _init_base_url(self): |
155 |
pass |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1132
diff
changeset
|
156 |
|
0 | 157 |
# overriden from cubicweb server configuration |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1132
diff
changeset
|
158 |
|
0 | 159 |
def sources(self): |
160 |
return {'system': {'adapter': 'gae'}} |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1132
diff
changeset
|
161 |
|
0 | 162 |
def load_schema(self, schemaclasses=None, extrahook=None): |
163 |
try: |
|
164 |
return self._schema |
|
165 |
except AttributeError: |
|
166 |
self._schema = load_schema(self, schemaclasses, extrahook) |
|
167 |
return self._schema |
|
168 |
||
169 |
# goa specific |
|
170 |
def repo_session(self, sessionid): |
|
171 |
return self.repository()._sessions[sessionid] |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1132
diff
changeset
|
172 |
|
0 | 173 |
def is_anonymous_user(self, login): |
174 |
if self['use-google-auth']: |
|
175 |
from google.appengine.api import users |
|
176 |
return users.get_current_user() is None |
|
177 |
else: |
|
178 |
return login == self.anonymous_user()[0] |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1132
diff
changeset
|
179 |