当前位置: 首页>>代码示例>>Python>>正文


Python IndexesHolder.unindexElement方法代码示例

本文整理汇总了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
开发者ID:davidmorrison,项目名称:indico,代码行数:71,代码来源:doh.py


注:本文中的MaKaC.common.indexes.IndexesHolder.unindexElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。