def store(filename, content, pf): if pf is None: pf = ProcessedFile(filename = filename) compressed = bz2.compress(content) pf.data = compressed pf.redo = False memcache.set(filename, compressed) pf.put() log_debug("Processed file %s", filename)
def store(filename, content, pf): if pf is None: pf = ProcessedFile(filename=filename) compressed = bz2.compress(content) pf.data = compressed pf.redo = False memcache.set(filename, compressed) pf.put() log_debug("Processed file %s", filename)
def notfound(msg=None): logging.info("file not found, msg = " + msg) print "Status: 404 Not Found" print CONTENT_TYPE print '<p>Not found</p>' if msg: print msg sys.exit() path_info = os.environ['PATH_INFO'] if path_info == '/': filename = 'help.txt.html' elif path_info in ('/de', '/de/'): filename = 'de/help.txt.html' else: m = re.match(r"/((?:de/)?(?:.*?\.txt|tags)\.html)$", path_info) if not m: notfound("illegal url") filename = m.group(1) cached = memcache.get(filename) if cached is not None: print CONTENT_TYPE print bz2.decompress(cached) else: record = ProcessedFile.all().filter('filename =', filename).get() if record is None: notfound("not in database") memcache.set(filename, record.data) print CONTENT_TYPE print bz2.decompress(record.data)
def notfound(msg = None): logging.info("file not found, msg = " + msg) print "Status: 404 Not Found" print CONTENT_TYPE print '<p>Not found</p>' if msg: print msg sys.exit() path_info = os.environ['PATH_INFO'] if path_info == '/': filename = 'help.txt.html' elif path_info in ('/de', '/de/'): filename = 'de/help.txt.html' else: m = re.match(r"/((?:de/)?(?:.*?\.txt|tags)\.html)$", path_info) if not m: notfound("illegal url") filename = m.group(1) cached = memcache.get(filename) if cached is not None: print CONTENT_TYPE print bz2.decompress(cached) else: record = ProcessedFile.all().filter('filename =', filename).get() if record is None: notfound("not in database") memcache.set(filename, record.data) print CONTENT_TYPE print bz2.decompress(record.data)