1 # copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
|
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
|
3 # |
|
4 # This file is part of CubicWeb. |
|
5 # |
|
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
|
7 # terms of the GNU Lesser General Public License as published by the Free |
|
8 # Software Foundation, either version 2.1 of the License, or (at your option) |
|
9 # any later version. |
|
10 # |
|
11 # CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
|
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
13 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
|
14 # details. |
|
15 # |
|
16 # You should have received a copy of the GNU Lesser General Public License along |
|
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
|
18 """ |
|
19 |
|
20 """ |
|
21 if __name__ == '__main__': |
|
22 |
|
23 from os.path import dirname, abspath |
|
24 from cubicweb import goa |
|
25 from cubicweb.goa.goaconfig import GAEConfiguration |
|
26 from cubicweb.goa.dbinit import create_user, create_groups |
|
27 |
|
28 # compute instance's root directory |
|
29 APPLROOT = dirname(abspath(__file__)) |
|
30 # apply monkey patches first |
|
31 goa.do_monkey_patch() |
|
32 # get instance's configuration (will be loaded from app.conf file) |
|
33 GAEConfiguration.ext_resources['JAVASCRIPTS'].append('DATADIR/goa.js') |
|
34 config = GAEConfiguration('toto', APPLROOT) |
|
35 # create default groups |
|
36 create_groups() |
|
37 if not config['use-google-auth']: |
|
38 # create default admin |
|
39 create_user('admin', 'admin', ('managers', 'users')) |
|
40 # create anonymous user if specified |
|
41 anonlogin = config['anonymous-user'] |
|
42 if anonlogin: |
|
43 create_user(anonlogin, config['anonymous-password'], ('guests',)) |
|
44 print 'content initialized' |
|