1 """special management views to manage repository content (initialization and |
1 """special management views to manage repository content (initialization and |
2 restoration). |
2 restoration). |
3 |
3 |
4 :organization: Logilab |
4 :organization: Logilab |
5 :copyright: 2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5 :copyright: 2008-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
6 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
6 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
7 """ |
7 """ |
8 __docformat__ = "restructuredtext en" |
8 __docformat__ = "restructuredtext en" |
9 |
9 |
10 from os.path import exists, join, abspath |
10 from os.path import exists, join, abspath |
11 from pickle import loads, dumps |
11 from pickle import loads, dumps |
12 |
12 |
13 from logilab.common.decorators import cached |
13 from logilab.common.decorators import cached |
14 from logilab.mtconverter import html_escape |
14 from logilab.mtconverter import html_escape |
15 |
15 |
|
16 from cubicweb.common.selectors import none_rset, match_user_groups |
16 from cubicweb.common.view import StartupView |
17 from cubicweb.common.view import StartupView |
17 from cubicweb.web import Redirect |
18 from cubicweb.web import Redirect |
18 from cubicweb.goa.dbinit import fix_entities, init_persistent_schema, insert_versions |
19 from cubicweb.goa.dbinit import fix_entities, init_persistent_schema, insert_versions |
19 |
20 |
20 from google.appengine.api.datastore import Entity, Key, Get, Put, Delete |
21 from google.appengine.api.datastore import Entity, Key, Get, Put, Delete |
37 class AuthInfo(StartupView): |
38 class AuthInfo(StartupView): |
38 """special management view to get cookie values to give to laxctl commands |
39 """special management view to get cookie values to give to laxctl commands |
39 which are doing datastore administration requests |
40 which are doing datastore administration requests |
40 """ |
41 """ |
41 id = 'authinfo' |
42 id = 'authinfo' |
42 require_groups = ('managers',) |
43 __selectors__ = (none_rset, match_user_groups('managers'),) |
43 |
44 |
44 def call(self): |
45 def call(self): |
45 cookie = self.req.get_cookie() |
46 cookie = self.req.get_cookie() |
46 values = [] |
47 values = [] |
47 if self.config['use-google-auth']: |
48 if self.config['use-google-auth']: |
59 class ContentInit(StartupView): |
60 class ContentInit(StartupView): |
60 """special management view to initialize content of a repository, |
61 """special management view to initialize content of a repository, |
61 step by step to avoid depassing quotas |
62 step by step to avoid depassing quotas |
62 """ |
63 """ |
63 id = 'contentinit' |
64 id = 'contentinit' |
64 require_groups = ('managers',) |
65 __selectors__ = (none_rset, match_user_groups('managers'),) |
65 |
66 |
66 def server_session(self): |
67 def server_session(self): |
67 ssession = self.config.repo_session(self.req.cnx.sessionid) |
68 ssession = self.config.repo_session(self.req.cnx.sessionid) |
68 ssession.set_pool() |
69 ssession.set_pool() |
69 return ssession |
70 return ssession |
164 self.w(u'<a href="%s">continue</a><br/>' % html_escape(self.req.url())) |
165 self.w(u'<a href="%s">continue</a><br/>' % html_escape(self.req.url())) |
165 |
166 |
166 |
167 |
167 class ContentClear(StartupView): |
168 class ContentClear(StartupView): |
168 id = 'contentclear' |
169 id = 'contentclear' |
169 require_groups = ('managers',) |
170 __selectors__ = (none_rset, match_user_groups('managers'),) |
170 skip_etypes = ('EGroup', 'EUser') |
171 skip_etypes = ('EGroup', 'EUser') |
171 |
172 |
172 def call(self): |
173 def call(self): |
173 # XXX should use unsafe_execute with all hooks deactivated |
174 # XXX should use unsafe_execute with all hooks deactivated |
174 # XXX step by catching datastore errors? |
175 # XXX step by catching datastore errors? |