From 0c920a2f05072a45c6570d67652e04770452727d Mon Sep 17 00:00:00 2001 From: Ruud Date: Sun, 22 Jan 2012 14:08:20 +0100 Subject: [PATCH] import send_from_directory inside the function itself --- couchpotato/core/plugins/base.py | 3 ++- couchpotato/core/plugins/file/main.py | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/couchpotato/core/plugins/base.py b/couchpotato/core/plugins/base.py index 87d6f75c..7a51b316 100644 --- a/couchpotato/core/plugins/base.py +++ b/couchpotato/core/plugins/base.py @@ -3,7 +3,6 @@ from couchpotato.core.event import fireEvent, addEvent from couchpotato.core.helpers.variable import getExt from couchpotato.core.logger import CPLog from couchpotato.environment import Env -from flask.helpers import send_from_directory from flask.templating import render_template_string from multipartpost import MultipartPostHandler from urlparse import urlparse @@ -67,6 +66,8 @@ class Plugin(object): def showStatic(self, filename): d = os.path.join(self.plugin_path, 'static') + + from flask.helpers import send_from_directory return send_from_directory(d, filename) def createFile(self, path, content, binary = False): diff --git a/couchpotato/core/plugins/file/main.py b/couchpotato/core/plugins/file/main.py index c42efa23..cf2481e0 100644 --- a/couchpotato/core/plugins/file/main.py +++ b/couchpotato/core/plugins/file/main.py @@ -7,8 +7,6 @@ from couchpotato.core.logger import CPLog from couchpotato.core.plugins.base import Plugin from couchpotato.core.settings.model import FileType, File from couchpotato.environment import Env -from flask.helpers import send_from_directory -from sqlalchemy.sql.expression import or_ import os.path log = CPLog(__name__) @@ -21,13 +19,14 @@ class FileManager(Plugin): addEvent('file.download', self.download) addEvent('file.types', self.getTypes) - addApiView('file.cache/', self.showImage) + addApiView('file.cache/', self.showCacheFile, static = True) - def showImage(self, filename = ''): + def showCacheFile(self, filename = ''): cache_dir = Env.get('cache_dir') filename = os.path.basename(filename) + from flask.helpers import send_from_directory return send_from_directory(cache_dir, filename) def download(self, url = '', dest = None, overwrite = False):