本文整理汇总了Python中camelot.core.orm.Session.refresh方法的典型用法代码示例。如果您正苦于以下问题:Python Session.refresh方法的具体用法?Python Session.refresh怎么用?Python Session.refresh使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类camelot.core.orm.Session
的用法示例。
在下文中一共展示了Session.refresh方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: model_run
# 需要导入模块: from camelot.core.orm import Session [as 别名]
# 或者: from camelot.core.orm.Session import refresh [as 别名]
def model_run( self, model_context ):
import sqlalchemy.exc as sa_exc
from camelot.core.orm import Session
from camelot.view import action_steps
from camelot.view.remote_signals import get_signal_handler
LOGGER.debug('session refresh requested')
progress_db_message = ugettext('Reload data from database')
progress_view_message = ugettext('Update screens')
session = Session()
signal_handler = get_signal_handler()
refreshed_objects = []
expunged_objects = []
#
# Loop over the objects one by one to be able to detect the deleted
# objects
#
session_items = len( session.identity_map )
for i, (_key, obj) in enumerate( session.identity_map.items() ):
try:
session.refresh( obj )
refreshed_objects.append( obj )
except sa_exc.InvalidRequestError:
#
# this object could not be refreshed, it was probably deleted
# outside the scope of this session, so assume it is deleted
# from the application its point of view
#
session.expunge( obj )
expunged_objects.append( obj )
if i%10 == 0:
yield action_steps.UpdateProgress( i,
session_items,
progress_db_message )
yield action_steps.UpdateProgress( text = progress_view_message )
for obj in refreshed_objects:
signal_handler.sendEntityUpdate( None, obj )
for obj in expunged_objects:
signal_handler.sendEntityDelete( None, obj )
yield action_steps.Refresh()