def setupInteractive(cls, connection, path, action, slideId='', questionAttrs=None, rollbackOption=None):
if Options['debug']:
print >> sys.stderr, 'sdserver.setupInteractive:', path, action, cls._interactiveSession
interactiveSession = UserIdMixin.get_path_base(cls._interactiveSession[1]) if cls._interactiveSession[1] else ''
basePath = UserIdMixin.get_path_base(path) if path else ''
if action == 'start':
if interactiveSession and interactiveSession != basePath:
raise Exception('There is already an interactive session: '+interactiveSession)
if not basePath:
return
cls._interactiveSession = (connection, path, slideId, questionAttrs)
cls._interactiveErrors = {}
if rollbackOption:
sdproxy.startTransactSession(basePath)
elif action in ('rollback', 'end'):
if not interactiveSession:
return
cls._interactiveSession = (None, '', '', None)
cls._interactiveErrors = {}
if sdproxy.transactionalSession(interactiveSession):
if action == 'rollback':
sdproxy.rollbackTransactSession(interactiveSession)
else:
sdproxy.endTransactSession(interactiveSession)
评论列表
文章目录