Python 通过导航方法调用学习CBV

Python 通过导航方法调用学习CBV,python,django,django-class-based-views,Python,Django,Django Class Based Views,我想通过查看从as_view()开始的函数调用过程来了解django基于类的视图。我在wsgi.py中设置了_trace()函数,如下所示: def tracefunc(frame, event, arg, indent=[0]): if event == "call": indent[0] += 2 #framea = sys._getframe( 0 ) print "-" * indent[0] + "> call function", fra

我想通过查看从as_view()开始的函数调用过程来了解django基于类的视图。我在wsgi.py中设置了_trace()函数,如下所示:

def tracefunc(frame, event, arg, indent=[0]):
  if event == "call":
      indent[0] += 2
      #framea = sys._getframe( 0 )
      print "-" * indent[0] + "> call function", frame.f_code.co_name, frame.f_code.co_filename 
  elif event == "return":
      print "<" + "-" * indent[0], "exit function", frame.f_code.co_name
      indent[0] -= 2
  return tracefunc

from django.core.wsgi import get_wsgi_application
sys.settrace(tracefunc)
application = get_wsgi_application()
def tracefunc(帧、事件、参数、缩进=[0]): 如果事件==“调用”: 缩进[0]+=2 #framea=sys.\u getframe(0) 打印“-”*缩进[0]+“>调用函数”,frame.f_code.co_名称,frame.f_code.co_文件名 elif事件==“返回”:
print“这实际上与您的问题无关,但是,因为您想学习cbv,您需要查看cbv inspector:是的,我已经使用了ccbv.co.uk。
由于_view
并没有真正运行视图,因此它会返回一个函数,该函数在调用视图时执行。
--------> call function process_request /usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py
----------> call function __init__ /usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py
------------> call function __init__ /usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py
<------------ exit function __init__
------------> call function _newname /usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py
<------------ exit function _newname
------------> call function _set_daemon /usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py
--------------> call function currentThread /usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py
----------------> call function __init__ /usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py
------------------> call function _newname /usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py
<------------------ exit function _newname
------------------> call function __init__ /usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py
--------------------> call function __init__ /usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py
<-------------------- exit function __init__
--------------------> call function _set_daemon /usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py
<-------------------- exit function _set_daemon
--------------------> call function Event /usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py