diff --git a/template.py b/template.py deleted file mode 100644 index a992c08..0000000 --- a/template.py +++ /dev/null @@ -1,136 +0,0 @@ -#! /usr/bin/env python -# -*- coding: utf-8 -*- - -class RemoteTemplate(object): - def __init__(self, source): - self.source = source - from wcs.qommon.misc import simplify - import os, urlparse - self.cache_key = simplify(urlparse.urlunparse(urlparse.urlparse(self.source)[:3] + ('', '', ''))) - self.cache_dirpath = os.path.join(publisher.app_dir, 'skeleton-cache') - self.cache_filepath = os.path.join(self.cache_dirpath, self.cache_key) - self.theme_skeleton_url = publisher.get_site_option('theme_skeleton_url') - self.skip_cache = (request.response.status_code != 200) - - def get_template_content(self): - import time, os, threading - if self.skip_cache: - return self.update_content() - from quixote import get_response, get_publisher - CACHE_REFRESH_TIMEOUT = 300 - self.response = get_response() - self.static_path = get_publisher().get_application_static_files_root_url() - try: - cache_filepath_mtime = min(( - os.stat(self.cache_filepath).st_mtime, - os.lstat(self.cache_filepath).st_mtime)) - except OSError: # missing file - return self.update_content() - else: - template_content = open(self.cache_filepath).read() - if time.time() > (cache_filepath_mtime + CACHE_REFRESH_TIMEOUT): - threading.Thread(target=self.update_content).start() - return template_content - - def update_content(self): - import requests - - r = requests.get(self.theme_skeleton_url, params={'source': self.source, 'format': 'ezt'}) - r.raise_for_status() - - body = """ - [if-any bigdiv]