def __init__(self, context): self.context = context template = self.context.template if not os.path.isabs(template): here = os.path.abspath(os.path.dirname(__file__)) template = os.path.join(here, template) self.root = meld3.parse_xml(template) self.callback = None
def index(self, url): template = os.path.join(_HERE, 'templates', 'errors.html') root = meld3.parse_xml(template) if self.errors: iterator = root.findmeld('error_li').repeat(self.errors) for li_element, error in iterator: t = li_element.findmeld('error_time') t.content(error.time) url = li_element.findmeld('error_url') url.attributes(href=error.url) url.content(error.description) else: content = root.findmeld('content') content.content('<h1>No Recent Errors</h1>', structure=True) return root.write_xhtmlstring()
def entry(self, identifier): template = os.path.join(_HERE, 'templates', 'entry.html') error = self.get_error(identifier) root = meld3.parse_xml(template) if error: header = root.findmeld('header') header.content('Error at %s' % error.time) text = root.findmeld('text') text.content(error.text) else: header = root.findmeld('header') header.content('Error Expired') text_area = root.findmeld('text_area') text_area.content( "<p>The error you're attempting to view has been flushed from " "the online error log history.</p>", structure=True) return root.write_xhtmlstring()
def __init__(self, app, global_conf=None, log_filename=DEFAULT_PROFILE_LOG, cachegrind_filename=None, discard_first_request=True, flush_at_shutdown = True, path='/__profile__', ): self.exists = os.path.exists # for __del__ self.remove = os.remove # for __del__ self.app = app self.profiler = profile.Profile() self.log_filename = log_filename self.cachegrind_filename = cachegrind_filename self.first_request = discard_first_request self.lock = threading.Lock() self.flush_at_shutdown = flush_at_shutdown self.path = path self.template = os.path.join(_HERE, 'profiler.html') self.meldroot = meld3.parse_xml(self.template)