Python HttpResponse.exception方法代码示例

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


Python HttpResponse.exception方法代码示例

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

示例1: process_request

# 需要导入模块: from django.http import HttpResponse [as 别名]
# 或者: from django.http.HttpResponse import exception [as 别名]
    def process_request(self, request):
        """
        load site config, return a dummy response if database seems
        uninitialized
        """
        #FIXME: can't we find a more efficient method?
        try:
            response = HttpResponse()
            response.status_code = UPDATE_STATUS_CODE

            config = siteconfig.load_site_config()
            db_buildversion = int(config.get(
                'BUILDVERSION', DEFAULT_BUILDVERSION))
            if db_buildversion < code_buildversion:
                response.db_buildversion = db_buildversion
                response.tt_buildversion = sys.maxint
            else:
                response.db_buildversion = sys.maxint

            db_tt_buildversion = int(config.get(
                'TT_BUILDVERSION', DEFAULT_TT_BUILDVERSION))
            if db_tt_buildversion < code_tt_buildversion:
                """
                Toolkit build version changed. clear stale quality checks data
                """
                logging.info(
                    "New Translate Toolkit version, flushing quality checks")
                dbupdate.flush_quality_checks()
                config.set('TT_BUILDVERSION', code_tt_buildversion)
                config.save()
                response.tt_buildversion = db_tt_buildversion

            if (response.db_buildversion, response.tt_buildversion) != (
                sys.maxint, sys.maxint):
                return response

        except Exception, e:
            #HACKISH: since exceptions thrown by different databases
            # do not share the same class heirarchy (DBAPI2 sucks) we
            # have to check the class name instead (since python uses
            # duck typing I will call this
            # poking-the-duck-until-it-quacks-like-a-duck-test

            if e.__class__.__name__ in (
                'OperationalError', 'ProgrammingError', 'DatabaseError'):
                # we can't build the database here cause caching
                # middleware won't allow progressive loading of
                # response so instead return an empty response marked
                # with special status code INSTALL_STATUS_CODE

                response = HttpResponse()
                response.status_code = INSTALL_STATUS_CODE
                response.exception = e
                return response
开发者ID:itsjeyd,项目名称:wikitrans-pootle,代码行数:56,代码来源:siteconfig.py

示例2: process_request

# 需要导入模块: from django.http import HttpResponse [as 别名]
# 或者: from django.http.HttpResponse import exception [as 别名]
    def process_request(self, request):
        """Load site config, return a dummy response if database seems
        uninitialized.
        """
        #FIXME: can't we find a more efficient method?
        try:
            response = HttpResponse()
            response.status_code = UPDATE_STATUS_CODE

            config = siteconfig.load_site_config()
            db_buildversion = int(config.get('BUILDVERSION',
                                             DEFAULT_BUILDVERSION))
            if db_buildversion < code_buildversion:
                response.db_buildversion = db_buildversion
                response.tt_buildversion = sys.maxint
            else:
                response.db_buildversion = sys.maxint

            db_tt_buildversion = int(config.get('TT_BUILDVERSION',
                                                DEFAULT_TT_BUILDVERSION))
            if (response.db_buildversion == sys.maxint and
                db_tt_buildversion < code_tt_buildversion):
                # Toolkit build version changed. Stale quality checks need to
                # be cleared. We can only do that safely when the db schema is
                # already up to date. The new toolkit version will be set by
                # dbupdate after it fixed things.
                response.tt_buildversion = db_tt_buildversion

            if ((response.db_buildversion, response.tt_buildversion) !=
                (sys.maxint, sys.maxint)):
                return response

        except Exception, e:
            #HACKISH: since exceptions thrown by different databases
            # do not share the same class heirarchy (DBAPI2 sucks) we
            # have to check the class name instead (since python uses
            # duck typing I will call this
            # poking-the-duck-until-it-quacks-like-a-duck-test

            if (e.__class__.__name__ in
                ('OperationalError', 'ProgrammingError', 'DatabaseError')):
                # we can't build the database here cause caching
                # middleware won't allow progressive loading of
                # response so instead return an empty response marked
                # with special status code INSTALL_STATUS_CODE

                response = HttpResponse()
                response.status_code = INSTALL_STATUS_CODE
                response.exception = e
                return response
开发者ID:ENuge,项目名称:pootle,代码行数:52,代码来源:siteconfig.py

本文标签属性:

示例:示例英文

代码:代码生成器

Python:python怎么读

HttpResponse:httpresponse是什么

exception:exceptions

上一篇:C# ISocket类代码示例
下一篇:名词解释自首(自首名词解释)(【自首是什么意思是什么意思自首是什么意思)

为您推荐