4 :organization: Logilab |
4 :organization: Logilab |
5 :copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
5 :copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
6 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
6 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
7 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
7 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
8 """ |
8 """ |
|
9 from __future__ import with_statement |
|
10 |
9 __docformat__ = "restructuredtext en" |
11 __docformat__ = "restructuredtext en" |
10 |
12 |
11 import sys |
13 import sys |
12 from datetime import datetime |
14 from datetime import datetime |
13 |
15 |
14 from logilab.common.shellutils import ProgressBar |
16 from logilab.common.shellutils import ProgressBar |
15 |
17 |
16 from cubicweb.schema import PURE_VIRTUAL_RTYPES |
18 from cubicweb.schema import PURE_VIRTUAL_RTYPES |
17 from cubicweb.server.sqlutils import SQL_PREFIX |
19 from cubicweb.server.sqlutils import SQL_PREFIX |
|
20 from cubicweb.server.session import security_enabled |
18 |
21 |
19 def has_eid(sqlcursor, eid, eids): |
22 def has_eid(sqlcursor, eid, eids): |
20 """return true if the eid is a valid eid""" |
23 """return true if the eid is a valid eid""" |
21 if eids.has_key(eid): |
24 if eids.has_key(eid): |
22 return eids[eid] |
25 return eids[eid] |
275 """ |
278 """ |
276 session = repo._get_session(cnx.sessionid, setpool=True) |
279 session = repo._get_session(cnx.sessionid, setpool=True) |
277 # yo, launch checks |
280 # yo, launch checks |
278 if checks: |
281 if checks: |
279 eids_cache = {} |
282 eids_cache = {} |
280 for check in checks: |
283 with security_enabled(session, read=False): # ensure no read security |
281 check_func = globals()['check_%s' % check] |
284 for check in checks: |
282 check_func(repo.schema, session, eids_cache, fix=fix) |
285 check_func = globals()['check_%s' % check] |
|
286 check_func(repo.schema, session, eids_cache, fix=fix) |
283 if fix: |
287 if fix: |
284 cnx.commit() |
288 cnx.commit() |
285 else: |
289 else: |
286 print |
290 print |
287 if not fix: |
291 if not fix: |