本文整理汇总了Python中MaKaC.common.indexes.IndexesHolder.unindexElement方法的典型用法代码示例。如果您正苦于以下问题:Python IndexesHolder.unindexElement方法的具体用法?Python IndexesHolder.unindexElement怎么用?Python IndexesHolder.unindexElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MaKaC.common.indexes.IndexesHolder
的用法示例。
在下文中一共展示了IndexesHolder.unindexElement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: findZombies
# 需要导入模块: from MaKaC.common.indexes import IndexesHolder [as 别名]
# 或者: from MaKaC.common.indexes.IndexesHolder import unindexElement [as 别名]
def findZombies(fix=False,fromDate=None):
dbi = DBMgr.getInstance()
dbi.startRequest()
pubConfIdx = IndexesHolder().getIndex('OAIDeletedConferenceModificationDate')
prvConfIdx = IndexesHolder().getIndex('OAIDeletedPrivateConferenceModificationDate')
pubContIdx = IndexesHolder().getIndex('OAIDeletedContributionModificationDate')
prvContIdx = IndexesHolder().getIndex('OAIDeletedPrivateContributionModificationDate')
zombies = []
doh = DeletedObjectHolder()
for obj in doh.getList():
isZombie = False
rec = None
if obj._objClass == Conference:
try:
rec = ConferenceHolder().getById(obj.getId())
isZombie = True
except:
continue
elif obj._objClass == Contribution or obj._objClass == AcceptedContribution:
try:
conference = ConferenceHolder().getById(obj.confId)
except:
continue
rec = conference.getContributionById(obj.contribId)
isZombie = (rec != None)
elif obj._objClass == SubContribution:
try:
conference = ConferenceHolder().getById(obj.confId)
except:
continue
contrib = conference.getContributionById(obj.contribId)
if not contrib:
continue
rec = contrib.getSubContributionById(obj.subContribId)
isZombie = (rec != None)
if isZombie:
print "-- ZOMBIE %s" % prettyPrint(rec)
zombies.append(obj)
if fix:
for z in zombies:
dbi.sync()
pubConfIdx.unindexElement(z)
prvConfIdx.unindexElement(z)
pubContIdx.unindexElement(z)
prvContIdx.unindexElement(z)
id = z.getId()
doh.remove(z)
dbi.commit()
print "-- FIXED %s " % id
dbi.endRequest()
print "\n Total of %s zombie records found" % len(zombies)
return zombies