def process_view(self, request, view_func, view_args, view_kwargs): """ If running with '--pdb', set a breakpoint at the start of each of each view before it gets called. """ # Skip out unless using `runserver --pdb`, # or `pdb` is in the command line parameters type_pdb = self.get_type_pdb(request) if not type_pdb: return try: filename = inspect.getsourcefile(view_func) except TypeError: if hasattr(view_func, "__class__"): filename = inspect.getsourcefile(view_func.__class__) lines, lineno = inspect.getsourcelines(view_func.__class__) else: raise else: lines, lineno = inspect.getsourcelines(view_func) basename = os.path.basename(filename) dirname = os.path.basename(os.path.dirname(filename)) temporary = True cond = None funcname = view_func.__name__ print print '%s %s' % (request.method, request.get_full_path()) print 'function "%s" in %s/%s:%d' % (funcname, dirname, basename, lineno) print 'args: %s' % (view_args,) print 'kwargs: %s' % (view_kwargs,) print if type_pdb == 'ipdb' and has_ipdb(): p = get_ipdb() else: if not type_pdb == 'pdb': print 'You do not install ipdb or ipython module' p = pdb.Pdb() p.reset() p.set_break(filename, lineno + 1, temporary, cond, funcname) sys.settrace(p.trace_dispatch)
def process_view(self, request, view_func, view_args, view_kwargs): """ If running with '--pdb', set a breakpoint at the start of each of each view before it gets called. """ # Skip out unless using `runserver --pdb`, # or `pdb` is in the command line parameters type_pdb = self.get_type_pdb(request) if not type_pdb: return filename = inspect.getsourcefile(view_func) basename = os.path.basename(filename) dirname = os.path.basename(os.path.dirname(filename)) lines, lineno = inspect.getsourcelines(view_func) temporary = True cond = None funcname = view_func.__name__ print print '%s %s' % (request.method, request.get_full_path()) print 'function "%s" in %s/%s:%d' % (funcname, dirname, basename, lineno) print 'args: %s' % (view_args,) print 'kwargs: %s' % (view_kwargs,) print if type_pdb == 'ipdb' and has_ipdb(): p = get_ipdb() else: if not type_pdb == 'pdb': print 'You do not install ipdb or ipython module' p = pdb.Pdb() p.reset() p.set_break(filename, lineno + 1, temporary, cond, funcname) sys.settrace(p.trace_dispatch)
def process_view(self, request, view_func, view_args, view_kwargs): """ If running with '--pdb', set a breakpoint at the start of each of each view before it gets called. """ # Skip out unless using `runserver --pdb`, # or `pdb` is in the command line parameters type_pdb = self.get_type_pdb(request) if not type_pdb: return filename = inspect.getsourcefile(view_func) basename = os.path.basename(filename) dirname = os.path.basename(os.path.dirname(filename)) lines, lineno = inspect.getsourcelines(view_func) temporary = True cond = None funcname = view_func.__name__ print() print('{} {}'.format(request.method, request.get_full_path())) print('function "{}" in {}/{}:{}'.format(funcname, dirname, basename, lineno)) print('args: {}'.format(view_args)) print('kwargs: {}'.format(view_kwargs)) print() if type_pdb == 'ipdb' and has_ipdb(): p = get_ipdb() else: if not type_pdb == 'pdb': print('You do not install ipdb or ipython module') p = pdb.Pdb() p.reset() p.set_break(filename, lineno + 1, temporary, cond, funcname) sys.settrace(p.trace_dispatch)