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


Python DBSession.remove方法代码示例

本文整理汇总了Python中stackone.model.DBSession.remove方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.remove方法的具体用法?Python DBSession.remove怎么用?Python DBSession.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在stackone.model.DBSession的用法示例。


在下文中一共展示了DBSession.remove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: do_work

# 需要导入模块: from stackone.model import DBSession [as 别名]
# 或者: from stackone.model.DBSession import remove [as 别名]

#.........这里部分代码省略.........
                            auth.user_name = self.user_name
                            auth.groups = groups
                            if result.get('email_address'):
                                auth.email_address = result['email_address']
                        #598
                    else:
                        logger.info(result['msg'])
                        raise Exception('Error in LDAP chcek: ' + result['msg'])
                    #598
                else:
                    auth.user = user
                    auth.user_name = user.user_name
                    auth.email_address = user.email_address
                #598
                TaskUtil.set_task_context(self.task_id)
                if recover != True and resume != True:
                    raw_result = self.exec_task(auth, self.context, *args, **kw)
                    #884
                else:
                    #884
                    runn = self.get_running_instance()
                    if runn:
                        self.curr_instance = runn.timestamp
                        #785
                    else:
                        #785
                        task_result = self.get_task_result_instance()
                        if isinstance(task_result.results, str):
                            task_result.results += 'can not resume task. No running instance'
                            #779
                        else:
                            #779
                            if not task_result.results:
                                task_result.results = 'can not resume task. No running instance'
                        task_result_running_instance = False
                    if task_result_running_instance:
                        #883
                        if recover == True:
                            raw_result = self.recover_task(auth, self.context, *args, **kw)
                            #884
                        else:
                            if resume == True:
                                raw_result = self.resume_task(auth, self.context, *args, **kw)
                if task_result_running_instance:
                    #1354
                    cancelled = False
                    results = raw_result
                    if isinstance(raw_result, dict):
                        #1152
                        if raw_result.get('status') == constants.TASK_CANCELED:
                            #1031
                            e = raw_result.get('msg') + '\n' + raw_result.get('results')
                            transaction.abort()
                            cancelled = True
                            if not self.quiet:
                                self.task_fail(e, auth, cancelled=True)
                            #1094
                        else:
                            if raw_result.get('status') == Task.SUCCEEDED:
                                results = raw_result.get('results')
                                visible = raw_result.get('visible', False)

                        if type(results)==dict:
                            #1148
                            if results.get('success')==True:
                                results = 'Task Completed Successfully.'

                    else:
                        #1355
                        if raw_result is not None and self.processors is not None:
                            #1250
                                #isinstance(raw_result, dict)
                            results = [raw_result]
                            for p in self.processors:
                                #1246
                                if issubclass(p, Processor):
                                    p().process_output(results)
                        else:
                            results = raw_result
                        if results is None:
                            #1340
                            desc_tuple = self.get_short_desc()
                            if desc_tuple is None:
                                results = 'Task Completed Successfully.'
                            else:
                                short_desc,short_desc_params = desc_tuple
                                desc = short_desc % short_desc_params
                                results = desc + ' Completed Successfully.'
                        transaction.commit()
            except Exception as e:
                logger.exception(to_str(e))
                transaction.abort()
                if not self.quiet:
                    self.task_fail(e, auth)
            else:
                if not self.quiet and cancelled == False:
                    self.task_success(results, visible)
        finally:
            DBSession.remove()
        return None
开发者ID:smarkm,项目名称:ovm,代码行数:104,代码来源:services.py


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