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


Python DbContainer.rollback_all方法代码示例

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


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

示例1: execute

# 需要导入模块: from pyasm.search import DbContainer [as 别名]
# 或者: from pyasm.search.DbContainer import rollback_all [as 别名]
    def execute(my):
        my.buffer = cStringIO.StringIO()

        try:
            try:

                # clear the main container for this thread
                Container.create()

                # clear the buffer
                WebContainer.clear_buffer()

                # initialize the web environment object and register it
                adapter = my.get_adapter()
                WebContainer.set_web(adapter)

                # get the display
                my._get_display()

            except SetupException, e:
                '''Display setup exception in the interface'''
                print "Setup exception: ", e.__str__()
                DbContainer.rollback_all()
                ExceptionLog.log(e)
                my.writeln("<h3>Tactic Setup Error</h3>" )
                my.writeln("<pre>" )
                my.writeln(e.__str__() )
                my.writeln("</pre>" )

            except DatabaseException, e:
                from tactic.ui.startup import DbConfigPanelWdg
                config_wdg = DbConfigPanelWdg()
                my.writeln("<pre>")
                my.writeln(config_wdg.get_buffer_display())
                my.writeln("</pre>")
开发者ID:talha81,项目名称:TACTIC-DEV,代码行数:37,代码来源:app_server.py

示例2: execute

# 需要导入模块: from pyasm.search import DbContainer [as 别名]
# 或者: from pyasm.search.DbContainer import rollback_all [as 别名]
    def execute(self):
        self.buffer = cStringIO.StringIO()
        error = None

        try:
            try:

                # clear the main container for this thread
                Container.create()

                # clear the buffer
                WebContainer.clear_buffer()

                # initialize the web environment object and register it
                adapter = self.get_adapter()
                WebContainer.set_web(adapter)

                # get the display
                self._get_display()

            except SetupException as e:
                '''Display setup exception in the interface'''
                print("Setup exception: ", e.__str__())
                DbContainer.rollback_all()
                ExceptionLog.log(e)
                self.writeln("<h3>Tactic Setup Error</h3>" )
                self.writeln("<pre>" )
                self.writeln(e.__str__() )
                self.writeln("</pre>" )
                error = "405: TACTIC Setup Error"

            except DatabaseException as e:
                from tactic.ui.startup import DbConfigPanelWdg
                config_wdg = DbConfigPanelWdg()
                self.writeln("<pre>")
                self.writeln(config_wdg.get_buffer_display())
                self.writeln("</pre>")
                error = "405: TACTIC Database Error"


            except Exception as e:
                stack_trace = ExceptionLog.get_stack_trace(e)
                #print(stack_trace)
                self.writeln("<pre>")
                self.writeln(stack_trace)
                self.writeln("</pre>")
                error = "405 %s" % str(e)

                # it is possible that the security object was not set
                security = Environment.get_security()
                if not security:
                    security = Security()
                    WebContainer.set_security(security)

                log = None
                # ensure that database connections are rolled back
                try:
                    DbContainer.rollback_all()
                except Exception as e2:
                    print("Error: Could not rollback: ", e2.__str__())
                    self.writeln("Error: Could not rollback: '%s'" % e2.__str__() )
                    stack_trace = ExceptionLog.get_stack_trace(e2)
                    print(stack_trace)
                    self.writeln("<pre>")
                    self.writeln(stack_trace)
                    self.writeln("</pre>")
                    raise e
                    #return


                try:
                    # WARNING: if this call causes an exception, the error
                    # will be obscure
                    log = ExceptionLog.log(e)
                except Exception as e2:

                    print("Error: Could not log exception: ", e2.__str__())
                    self.writeln("Error '%s': Could not log exception" % e2.__str__() )
                    stack_trace = ExceptionLog.get_stack_trace(e2)
                    print(stack_trace)
                    self.writeln("<pre>")
                    self.writeln(stack_trace)
                    self.writeln("</pre>")
                    return

                self.writeln("<pre>")
                self.writeln("An Error has occurred.  Please see your Tactic Administrator<br/>")
                self.writeln( "Error Message: %s" % log.get_value("message") )
                self.writeln("Error Id: %s" % log.get_id() )
                #self.writeln( log.get_value("stack_trace") )
                self.writeln("</pre>")


        finally:
            # ensure that database connections are always closed
            DbContainer.close_all()
            # clear the container
            Container.delete()
            WebContainer.get_buffer().write( self.buffer.getvalue() )

#.........这里部分代码省略.........
开发者ID:mincau,项目名称:TACTIC,代码行数:103,代码来源:app_server.py


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