server/checkintegrity.py
changeset 2596 d02eed70937f
parent 2476 1294a6bdf3bf
child 3374 d5bd1b659ce8
equal deleted inserted replaced
2595:e76bf303c6f2 2596:d02eed70937f
    11 import sys
    11 import sys
    12 from datetime import datetime
    12 from datetime import datetime
    13 
    13 
    14 from logilab.common.shellutils import ProgressBar
    14 from logilab.common.shellutils import ProgressBar
    15 
    15 
       
    16 from cubicweb.schema import PURE_VIRTUAL_RTYPES
    16 from cubicweb.server.sqlutils import SQL_PREFIX
    17 from cubicweb.server.sqlutils import SQL_PREFIX
    17 
    18 
    18 def has_eid(sqlcursor, eid, eids):
    19 def has_eid(sqlcursor, eid, eids):
    19     """return true if the eid is a valid eid"""
    20     """return true if the eid is a valid eid"""
    20     if eids.has_key(eid):
    21     if eids.has_key(eid):
   194 
   195 
   195 def check_relations(schema, session, eids, fix=1):
   196 def check_relations(schema, session, eids, fix=1):
   196     """check all relations registered in the repo system table"""
   197     """check all relations registered in the repo system table"""
   197     print 'Checking relations'
   198     print 'Checking relations'
   198     for rschema in schema.relations():
   199     for rschema in schema.relations():
   199         if rschema.is_final():
   200         if rschema.is_final() or rschema in PURE_VIRTUAL_RTYPES:
   200             continue
       
   201         if rschema == 'identity':
       
   202             continue
   201             continue
   203         if rschema.inlined:
   202         if rschema.inlined:
   204             for subjtype in rschema.subjects():
   203             for subjtype in rschema.subjects():
   205                 table = SQL_PREFIX + str(subjtype)
   204                 table = SQL_PREFIX + str(subjtype)
   206                 column = SQL_PREFIX +  str(rschema)
   205                 column = SQL_PREFIX +  str(rschema)