Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5483)

Unified Diff: chrome/common/extensions/docs/server2/template_fetcher.py

Issue 10545043: Extensions docs server: Design changes, partial template support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Made suggested changes Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/server2/template_fetcher.py
diff --git a/chrome/common/extensions/docs/server2/template_fetcher.py b/chrome/common/extensions/docs/server2/template_fetcher.py
deleted file mode 100644
index d15d413e88556ca5ed57fb12f9d49767140f0a98..0000000000000000000000000000000000000000
--- a/chrome/common/extensions/docs/server2/template_fetcher.py
+++ /dev/null
@@ -1,39 +0,0 @@
-# Copyright (c) 2012 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import logging
-import os
-import time
-
-from third_party.handlebar import Handlebar
-
-# Cache templates for 5 minutes.
-CACHE_TIMEOUT = 300
-
-# Cached templates stored as (branch, path) -> (template, cache time)
-# The template cache is global so it will not be erased each time a new
-# TemplateFetcher is created.
-TEMPLATE_CACHE = {}
-
-class TemplateFetcher(object):
- def __init__(self, branch, fetcher):
- self._fetcher = fetcher
- self._branch = branch
-
- def __getitem__(self, path):
- key = (self._branch, path)
- if key in TEMPLATE_CACHE:
- compiled_template, compile_time = TEMPLATE_CACHE[key]
- if (time.clock() - compile_time) > CACHE_TIMEOUT:
- TEMPLATE_CACHE.pop(key)
- if key not in TEMPLATE_CACHE:
- logging.info('Template cache miss for: ' + path)
- try:
- template = self._fetcher.FetchResource(self._branch, path).content
- compiled_template = Handlebar(template)
- TEMPLATE_CACHE[key] = (compiled_template, time.clock())
- except:
- return ''
-
- return compiled_template

Powered by Google App Engine
This is Rietveld 408576698