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


Python middleware.DebugToolbarMiddleware类代码示例

本文整理汇总了Python中debug_toolbar.middleware.DebugToolbarMiddleware的典型用法代码示例。如果您正苦于以下问题:Python DebugToolbarMiddleware类的具体用法?Python DebugToolbarMiddleware怎么用?Python DebugToolbarMiddleware使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_tuple_urlconf

 def test_tuple_urlconf(self):
     request = rf.get('/')
     urls = __import__('tests.urls').urls
     urls.urlpatterns = tuple(urls.urlpatterns)
     request.urlconf = urls
     middleware = DebugToolbarMiddleware()
     with Settings(INTERNAL_IPS=['127.0.0.1'], DEBUG=True):
         middleware.process_request(request)
         self.assertFalse(isinstance(request.urlconf, basestring))
开发者ID:CLKUY,项目名称:django-debug-toolbar,代码行数:9,代码来源:tests.py

示例2: test_show_toolbar_TEST

    def test_show_toolbar_TEST(self):
        request = rf.get('/')
        middleware = DebugToolbarMiddleware()

        with Settings(INTERNAL_IPS=['127.0.0.1'], TEST=True, DEBUG=True):
            self.assertFalse(middleware._show_toolbar(request))

        with Settings(INTERNAL_IPS=['127.0.0.1'], TEST=False, DEBUG=True):
            self.assertTrue(middleware._show_toolbar(request))
开发者ID:CLKUY,项目名称:django-debug-toolbar,代码行数:9,代码来源:tests.py

示例3: test_request_urlconf_string

    def test_request_urlconf_string(self):
        request = rf.get('/')
        set_urlconf('tests.urls')
        middleware = DebugToolbarMiddleware()

        middleware.process_request(request)

        patterns = get_resolver(get_urlconf()).url_patterns
        self.assertTrue(hasattr(patterns[1], '_callback_str'))
        self.assertEqual(patterns[-1]._callback_str, 'tests.views.execute_sql')
开发者ID:nazyacom,项目名称:django-debug-toolbar,代码行数:10,代码来源:test_integration.py

示例4: test_tuple_urlconf

    def test_tuple_urlconf(self):
        request = rf.get('/')
        urls = __import__('tests.urls').urls
        urls.urlpatterns = tuple(urls.urlpatterns)
        request.urlconf = urls
        middleware = DebugToolbarMiddleware()

        middleware.process_request(request)

        self.assertFalse(isinstance(request.urlconf, six.string_types))
开发者ID:nazyacom,项目名称:django-debug-toolbar,代码行数:10,代码来源:test_integration.py

示例5: test_show_toolbar_TEST

    def test_show_toolbar_TEST(self):
        request = self.request

        middleware = DebugToolbarMiddleware()

        with Settings(TEST=True, DEBUG=True):
            self.assertFalse(middleware._show_toolbar(request))

        with Settings(TEST=False, DEBUG=True):
            self.assertTrue(middleware._show_toolbar(request))
开发者ID:Torkn,项目名称:django-debug-toolbar,代码行数:10,代码来源:tests.py

示例6: test_show_toolbar_INTERNAL_IPS

    def test_show_toolbar_INTERNAL_IPS(self):
        request = self.request

        request.META = {"REMOTE_ADDR": "127.0.0.1"}
        middleware = DebugToolbarMiddleware()

        with Settings(INTERNAL_IPS=["127.0.0.1"], DEBUG=True):
            self.assertTrue(middleware._show_toolbar(request))

        with Settings(INTERNAL_IPS=[], DEBUG=True):
            self.assertFalse(middleware._show_toolbar(request))
开发者ID:jasonkeene,项目名称:django-debug-toolbar,代码行数:11,代码来源:tests.py

示例7: test_show_toolbar_INTERNAL_IPS

    def test_show_toolbar_INTERNAL_IPS(self):
        request = rf.get('/')

        request.META = {'REMOTE_ADDR': '127.0.0.1'}
        middleware = DebugToolbarMiddleware()

        with Settings(INTERNAL_IPS=['127.0.0.1'], DEBUG=True):
            self.assertTrue(middleware._show_toolbar(request))

        with Settings(INTERNAL_IPS=[], DEBUG=True):
            self.assertFalse(middleware._show_toolbar(request))
开发者ID:CLKUY,项目名称:django-debug-toolbar,代码行数:11,代码来源:tests.py

示例8: test_show_toolbar_TEST

    def test_show_toolbar_TEST(self):
        request = self.request
        
        request.META = {'REMOTE_ADDR': '127.0.0.1'}
        middleware = DebugToolbarMiddleware()
        
        with Settings(INTERNAL_IPS=['127.0.0.1'], TEST=True, DEBUG=True):
            self.assertFalse(middleware._show_toolbar(request))

        with Settings(INTERNAL_IPS=['127.0.0.1'], TEST=False, DEBUG=True):
            self.assertTrue(middleware._show_toolbar(request))
开发者ID:hakanw,项目名称:django-debug-toolbar,代码行数:11,代码来源:tests.py

示例9: test_request_urlconf_string

    def test_request_urlconf_string(self):
        request = rf.get('/')
        request.urlconf = 'tests.urls'
        middleware = DebugToolbarMiddleware()

        with Settings(INTERNAL_IPS=['127.0.0.1'], DEBUG=True):
            middleware.process_request(request)

            self.assertFalse(isinstance(request.urlconf, basestring))

            self.assertTrue(hasattr(request.urlconf.urlpatterns[1], '_callback_str'))
            self.assertEquals(request.urlconf.urlpatterns[-1]._callback_str, 'tests.views.execute_sql')
开发者ID:hane2009,项目名称:django-debug-toolbar,代码行数:12,代码来源:tests.py

示例10: test_request_urlconf_module

    def test_request_urlconf_module(self):
        request = rf.get('/')
        request.urlconf = __import__('tests.urls').urls
        middleware = DebugToolbarMiddleware()

        with self.settings(INTERNAL_IPS=['127.0.0.1'], DEBUG=True):
            middleware.process_request(request)

            self.assertFalse(isinstance(request.urlconf, six.string_types))

            self.assertTrue(hasattr(request.urlconf.urlpatterns[1], '_callback_str'))
            self.assertEqual(request.urlconf.urlpatterns[-1]._callback_str, 'tests.views.execute_sql')
开发者ID:gfzhao,项目名称:django-debug-toolbar,代码行数:12,代码来源:tests.py

示例11: test_request_urlconf_module

    def test_request_urlconf_module(self):
        request = rf.get('/')
        request.urlconf = __import__('tests.urls').urls
        middleware = DebugToolbarMiddleware()

        middleware.process_request(request)

        self.assertFalse(isinstance(request.urlconf, six.string_types))

        patterns = request.urlconf.urlpatterns
        self.assertTrue(hasattr(patterns[1], '_callback_str'))
        self.assertEqual(patterns[-1]._callback_str, 'tests.views.execute_sql')
开发者ID:nazyacom,项目名称:django-debug-toolbar,代码行数:12,代码来源:test_integration.py

示例12: test_request_urlconf_string

    def test_request_urlconf_string(self):
        request = self.request

        request.urlconf = "tests.urls"
        request.META = {"REMOTE_ADDR": "127.0.0.1"}
        middleware = DebugToolbarMiddleware()

        with Settings(INTERNAL_IPS=["127.0.0.1"], DEBUG=True):
            middleware.process_request(request)

            self.assertFalse(isinstance(request.urlconf, basestring))

            self.assertTrue(hasattr(request.urlconf.urlpatterns[0], "_callback_str"))
            self.assertEquals(request.urlconf.urlpatterns[0]._callback_str, "debug_toolbar.views.debug_media")
            self.assertEquals(request.urlconf.urlpatterns[-1].urlconf_name.__name__, "tests.urls")
开发者ID:jasonkeene,项目名称:django-debug-toolbar,代码行数:15,代码来源:tests.py

示例13: test_request_urlconf_string

    def test_request_urlconf_string(self):
        request = self.request

        request.urlconf = 'debug_toolbar.tests.urls'
        request.META = {'REMOTE_ADDR': '127.0.0.1'}
        middleware = DebugToolbarMiddleware()

        with Settings(DEBUG=True):
            middleware.process_request(request)

            self.assertFalse(isinstance(request.urlconf, basestring))

            self.assertTrue(hasattr(request.urlconf.urlpatterns[0], '_callback_str'))
            self.assertEquals(request.urlconf.urlpatterns[0]._callback_str, 'debug_toolbar.views.debug_media')
            self.assertEquals(request.urlconf.urlpatterns[-1].urlconf_name.__name__, 'debug_toolbar.tests.urls')
开发者ID:Torkn,项目名称:django-debug-toolbar,代码行数:15,代码来源:tests.py

示例14: execute_command

def execute_command(func,self,*args,**options):

    command = args[0]
    start = datetime.now()
    result = func(self,*args,**options)

    stop = datetime.now()
    duration = ms_from_timedelta(stop - start)

    #TODO find more better way to get the calling func info
    calframe = _get_func_info()

    params = {
        'func':calframe[4][3],
        'func_path':"{}:{}".format(calframe[4][1],calframe[4][2]),
        'command':command,
        'result':result,
        'start_time':start,
        'stop_time':stop,
        'duration':duration,
        'is_slow':None,

    }

    #TODO more better way to loggging?
    djdt = DebugToolbarMiddleware.get_current()
    if not djdt:
        return result
    logger = djdt.get_panel(RedisDebugPanel)
    logger.record(**params)

    return result
开发者ID:shootstar,项目名称:redis_logger,代码行数:32,代码来源:redis_logger.py

示例15: test_request_urlconf_module

 def test_request_urlconf_module(self):
     request = self.request
     
     request.urlconf = __import__('tests.urls').urls
     request.META = {'REMOTE_ADDR': '127.0.0.1'}
     middleware = DebugToolbarMiddleware()
     
     with Settings(INTERNAL_IPS=['127.0.0.1'], DEBUG=True):
         middleware.process_request(request)
         
         self.assertFalse(isinstance(request.urlconf, basestring))
         
         self.assertTrue(hasattr(request.urlconf.urlpatterns[0], '_callback_str'))
         self.assertEquals(request.urlconf.urlpatterns[0]._callback_str, 'debug_toolbar.views.debug_media')
         self.assertTrue(hasattr(request.urlconf.urlpatterns[1], '_callback_str'))
         self.assertEquals(request.urlconf.urlpatterns[-1]._callback_str, 'tests.views.execute_sql')
开发者ID:hakanw,项目名称:django-debug-toolbar,代码行数:16,代码来源:tests.py


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