本文整理汇总了Python中ckan.model.meta.Session.rollback方法的典型用法代码示例。如果您正苦于以下问题:Python Session.rollback方法的具体用法?Python Session.rollback怎么用?Python Session.rollback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ckan.model.meta.Session
的用法示例。
在下文中一共展示了Session.rollback方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: clean_harvest_log
# 需要导入模块: from ckan.model.meta import Session [as 别名]
# 或者: from ckan.model.meta.Session import rollback [as 别名]
def clean_harvest_log(condition):
Session.query(HarvestLog).filter(HarvestLog.created <= condition).delete(synchronize_session=False)
try:
Session.commit()
except InvalidRequestError:
Session.rollback()
log.error("An error occurred while trying to clean-up the harvest log table")
log.info("Harvest log table clean-up finished successfully")
示例2: create
# 需要导入模块: from ckan.model.meta import Session [as 别名]
# 或者: from ckan.model.meta.Session import rollback [as 别名]
def create(cls, message, job):
"""
Helper function to create an error object and save it.
"""
err = cls(message=message, job=job)
try:
err.save()
except InvalidRequestError:
Session.rollback()
err.save()
finally:
# No need to alert administrator so don't log as an error
log.info(message)
示例3: create
# 需要导入模块: from ckan.model.meta import Session [as 别名]
# 或者: from ckan.model.meta.Session import rollback [as 别名]
def create(cls, message, object, stage=u'Fetch', line=None):
'''
Helper function to create an error object and save it.
'''
err = cls(message=message, object=object,
stage=stage, line=line)
try:
err.save()
except InvalidRequestError:
Session.rollback()
err.save()
finally:
log_message = '{0}, line {1}'.format(message, line) \
if line else message
log.debug(log_message)