diff --git a/loris/img.py b/loris/img.py index 797d2ad2..ce35fa50 100644 --- a/loris/img.py +++ b/loris/img.py @@ -13,6 +13,7 @@ from loris_exception import ImageException from urllib import unquote, quote_plus from werkzeug.http import generate_etag +from urllib import unquote logger = getLogger(__name__) @@ -223,7 +224,7 @@ def __setitem__(self, image_request, fp): # Does this make sense? It's a little strange because we already know # the cache root in the webapp. We'll use the Image object (the key) # to make any additional smlinks. - canonical_fp = path.join(self._links_root, image_request.c14n_cache_path) + canonical_fp = path.join(self._links_root, unquote(image_request.c14n_cache_path)) ImageCache._link(fp, canonical_fp) if not image_request.is_canonical: alt_fp = path.join(self._links_root, image_request.cache_path) @@ -246,8 +247,7 @@ def get(self, image_request): return None def _get_cache_path(self, image_request): - return path.realpath(path.join(self._links_root, image_request.cache_path)) - - - - + return path.realpath(path.join(self._links_root, unquote(image_request.cache_path))) + # Every request would need the info in order to determine the canonical path: + # return path.realpath(path.join(self._links_root, unquote(image_request.c14n_cache_path))) + # is it worth it? diff --git a/loris/img_info.py b/loris/img_info.py index c5278b53..b5892745 100644 --- a/loris/img_info.py +++ b/loris/img_info.py @@ -15,6 +15,7 @@ import json import os import struct +from urllib import unquote try: from collections import OrderedDict @@ -320,10 +321,10 @@ def __init__(self, root, size=500): self._lock = Lock() def _get_info_fp(self,ident): - return os.path.join(self.root,ident,'info.json') + return os.path.join(self.root, unquote(ident), 'info.json') def _get_color_profile_fp(self,ident): - return os.path.join(self.root,ident,'profile.icc') + return os.path.join(self.root, unquote(ident), 'profile.icc') def get(self, ident): ''' diff --git a/loris/webapp.py b/loris/webapp.py index 77afb063..c79ec8a3 100755 --- a/loris/webapp.py +++ b/loris/webapp.py @@ -494,7 +494,7 @@ def get_img(self, request, ident, region, size, rotation, quality, target_fmt, b # accessed, which mean we don't have to catch any exceptions here. image_request = img.ImageRequest(ident, region, size, rotation, quality, target_fmt) - logger.debug(image_request.request_path) + logger.debug('Image Request Path: %s' % (image_request.request_path,)) if self.enable_caching: in_cache = image_request in self.img_cache @@ -539,8 +539,8 @@ def get_img(self, request, ident, region, size, rotation, quality, target_fmt, b # 1. Resolve the identifier src_fp, src_format = self.resolver.resolve(ident) + # 2. Hand the Image object its info - # IT'S HERE info = self._get_info(ident, request, base_uri, src_fp, src_format)[0] image_request.info = info