server/checkintegrity.py
changeset 8562 0d2fb4604265
parent 8527 6151b0199bc1
child 8578 f6ea4ea63d57
equal deleted inserted replaced
8561:77ea3eed9946 8562:0d2fb4604265
     1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     1 # copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     3 #
     3 #
     4 # This file is part of CubicWeb.
     4 # This file is part of CubicWeb.
     5 #
     5 #
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
    30 
    30 
    31 from logilab.common.shellutils import ProgressBar
    31 from logilab.common.shellutils import ProgressBar
    32 
    32 
    33 from cubicweb.schema import PURE_VIRTUAL_RTYPES, VIRTUAL_RTYPES
    33 from cubicweb.schema import PURE_VIRTUAL_RTYPES, VIRTUAL_RTYPES
    34 from cubicweb.server.sqlutils import SQL_PREFIX
    34 from cubicweb.server.sqlutils import SQL_PREFIX
    35 from cubicweb.server.session import security_enabled
       
    36 
    35 
    37 def notify_fixed(fix):
    36 def notify_fixed(fix):
    38     if fix:
    37     if fix:
    39         sys.stderr.write(' [FIXED]')
    38         sys.stderr.write(' [FIXED]')
    40     sys.stderr.write('\n')
    39     sys.stderr.write('\n')
   392     """
   391     """
   393     session = repo._get_session(cnx.sessionid, setcnxset=True)
   392     session = repo._get_session(cnx.sessionid, setcnxset=True)
   394     # yo, launch checks
   393     # yo, launch checks
   395     if checks:
   394     if checks:
   396         eids_cache = {}
   395         eids_cache = {}
   397         with security_enabled(session, read=False, write=False): # ensure no read security
   396         with session.security_enabled(read=False, write=False): # ensure no read security
   398             for check in checks:
   397             for check in checks:
   399                 check_func = globals()['check_%s' % check]
   398                 check_func = globals()['check_%s' % check]
   400                 check_func(repo.schema, session, eids_cache, fix=fix)
   399                 check_func(repo.schema, session, eids_cache, fix=fix)
   401         if fix:
   400         if fix:
   402             cnx.commit()
   401             cnx.commit()