--- a/server/checkintegrity.py Wed Feb 24 10:30:31 2010 +0100
+++ b/server/checkintegrity.py Wed Feb 24 10:32:22 2010 +0100
@@ -64,7 +64,7 @@
else:
yield eschema
-def reindex_entities(schema, session):
+def reindex_entities(schema, session, withpb=True):
"""reindex all entities in the repository"""
# deactivate modification_date hook since we don't want them
# to be updated due to the reindexation
@@ -92,20 +92,23 @@
etypes.add(container)
print 'Reindexing entities of type %s' % \
', '.join(sorted(str(e) for e in etypes))
- pb = ProgressBar(len(etypes) + 1)
+ if withpb:
+ pb = ProgressBar(len(etypes) + 1)
# first monkey patch Entity.check to disable validation
from cubicweb.entity import Entity
_check = Entity.check
Entity.check = lambda self, creation=False: True
# clear fti table first
session.system_sql('DELETE FROM %s' % session.repo.system_source.dbhelper.fti_table)
- pb.update()
+ if withpb:
+ pb.update()
# reindex entities by generating rql queries which set all indexable
# attribute to their current value
for eschema in etypes:
for entity in session.execute('Any X WHERE X is %s' % eschema).entities():
FTIndexEntityOp(session, entity=entity)
- pb.update()
+ if withpb:
+ pb.update()
# restore Entity.check
Entity.check = _check
@@ -276,7 +279,7 @@
print >> sys.stderr
-def check(repo, cnx, checks, reindex, fix):
+def check(repo, cnx, checks, reindex, fix, withpb=True):
"""check integrity of instance's repository,
using given user and password to locally connect to the repository
(no running cubicweb server needed)
@@ -297,5 +300,5 @@
if reindex:
cnx.rollback()
session.set_pool()
- reindex_entities(repo.schema, session)
+ reindex_entities(repo.schema, session, withpb=withpb)
cnx.commit()
--- a/server/test/unittest_checkintegrity.py Wed Feb 24 10:30:31 2010 +0100
+++ b/server/test/unittest_checkintegrity.py Wed Feb 24 10:32:22 2010 +0100
@@ -20,7 +20,7 @@
sys.stderr = sys.stdout = StringIO()
try:
check(repo, cnx, ('entities', 'relations', 'text_index', 'metadata'),
- True, True)
+ reindex=True, fix=True, withpb=False)
finally:
sys.stderr = sys.__stderr__
sys.stdout = sys.__stdout__