Download:
child 44:51371d1b3578
parent 42:f40091264dcb
43:d9569e15bcc3
Anton Shestakov <av6@dwimlabs.net>, Mon, 28 Sep 2015 00:03:36 +0800
viewer: compute a weak entity tag from db and repo mtime This saves running a subprocess with hg -Tjson and rendering pages when there weren't any updates to the testhg repo or to the database. Maybe ETag is not the perfect place for this (Last-Modified?), but it works.

1 файлов изменено, 12 вставок(+), 0 удалений(-) [+]
viewer.py file | annotate | diff | comparison | revisions
--- a/viewer.py Sun Sep 27 22:35:27 2015 +0800
+++ b/viewer.py Mon Sep 28 00:03:36 2015 +0800
@@ -2,6 +2,7 @@
import colorsys
import json
import logging
+import os
import re
import sqlite3
import subprocess
@@ -50,6 +51,11 @@
class ResultsHandler(BaseHandler):
def get(self, ext):
+ self.set_etag_header()
+ if self.check_etag_header():
+ self.set_status(304)
+ return
+
if ext == 'tsv':
self.results_tsv()
elif ext == 'asc':
@@ -57,6 +63,12 @@
elif ext == 'html':
self.results_html()
+ def compute_etag(self):
+ dbmt = os.stat(DBPATH).st_mtime
+ changelog = os.path.join(TESTHGREPO, '.hg', 'store', '00changelog.i')
+ repomt = os.stat(changelog).st_mtime
+ return 'W/"{},{}"'.format(dbmt, repomt)
+
def getchangesets(self):
rev = self.get_argument('rev', 'tip')
revcount = 120