本文整理汇总了Python中MaKaC.conference.CategoryManager.hasAnyProtection方法的典型用法代码示例。如果您正苦于以下问题:Python CategoryManager.hasAnyProtection方法的具体用法?Python CategoryManager.hasAnyProtection怎么用?Python CategoryManager.hasAnyProtection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MaKaC.conference.CategoryManager
的用法示例。
在下文中一共展示了CategoryManager.hasAnyProtection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: guessProtection
# 需要导入模块: from MaKaC.conference import CategoryManager [as 别名]
# 或者: from MaKaC.conference.CategoryManager import hasAnyProtection [as 别名]
def guessProtection(fix=False,fromDate=None):
""" Recreate deleted obj indices, from the DOH, guessing the protection,
using the parent category"""
dbi = DBMgr.getInstance()
dbi.startRequest()
doh = DeletedObjectHolder()
if fromDate:
fromDateParsed_tz = datetime.datetime(*time.strptime(fromDate,'%Y-%m-%d')[:6],**{'tzinfo':timezone('UTC')})
fromDateParsed_naive = datetime.datetime(*time.strptime(fromDate,'%Y-%m-%d')[:6])
for obj in doh.getList():
if fromDate:
if obj.getOAIModificationDate().tzinfo:
fromDateParsed = fromDateParsed_tz
else:
fromDateParsed = fromDateParsed_naive
if obj.getOAIModificationDate() < fromDateParsed:
continue
if not hasattr(obj, 'protected'):
try:
categ = CategoryManager().getById(obj.getCategoryPath()[-1])
obj.protected = categ.hasAnyProtection()
print "-- protection for %s set as %s" % (prettyPrint(obj), obj.protected)
except KeyError:
print ">> CATEGORY %s for %s no longer exists - assuming TRUE" % (obj.getCategoryPath()[-1], prettyPrint(obj))
obj.protected = True
dbi.commit()
else:
print "** protection for %s was already at %s" % (prettyPrint(obj), obj.protected)
dbi.endRequest()