def should_stop_on_django_breakpoint(self, frame, event, arg): mainDebugger = self._args[0] thread = self._args[3] flag = False template_frame_file = get_template_file_name(frame) #pydev_log.debug("Django is rendering a template: %s\n" % template_frame_file) django_breakpoints_for_file = mainDebugger.django_breakpoints.get(template_frame_file) if django_breakpoints_for_file: #pydev_log.debug("Breakpoints for that file: %s\n" % django_breakpoints_for_file) template_frame_line = get_template_line(frame, template_frame_file) #pydev_log.debug("Tracing template line: %d\n" % template_frame_line) if DictContains(django_breakpoints_for_file, template_frame_line): django_breakpoint = django_breakpoints_for_file[template_frame_line] if django_breakpoint.is_triggered(template_frame_file, template_frame_line): #pydev_log.debug("Breakpoint is triggered.\n") flag = True new_frame = DjangoTemplateFrame( frame, template_frame_file=template_frame_file, template_frame_line=template_frame_line, ) if django_breakpoint.condition is not None: try: val = eval(django_breakpoint.condition, new_frame.f_globals, new_frame.f_locals) if not val: flag = False pydev_log.debug("Condition '%s' is evaluated to %s. Not suspending.\n" % (django_breakpoint.condition, val)) except: pydev_log.info( 'Error while evaluating condition \'%s\': %s\n' % (django_breakpoint.condition, sys.exc_info()[1])) if django_breakpoint.expression is not None: try: try: val = eval(django_breakpoint.expression, new_frame.f_globals, new_frame.f_locals) except: val = sys.exc_info()[1] finally: if val is not None: thread.additionalInfo.message = val if flag: frame = suspend_django(self, mainDebugger, thread, frame) return flag, frame
def is_triggered(self, frame): file = get_template_file_name(frame) line = get_template_line(frame) return self.file == file and self.line == line