Permalink
Browse files

Introduced a full set of path possibilities to Disk cache configuration

  • Loading branch information...
migurski
migurski committed Apr 24, 2010
1 parent bbbd0cb commit 6e0d99aab49ba691233cf7cad483b445fee96243
Showing with 25 additions and 3 deletions.
  1. +24 −2 TileStache/Config.py
  2. +1 −1 tilestache.cgi
View
@@ -47,7 +47,7 @@
from sys import stderr
from os.path import realpath, join as pathjoin
-from urlparse import urljoin
+from urlparse import urljoin, urlparse
try:
from json import dumps as json_dumps
@@ -96,7 +96,29 @@ def _parseConfigfileCache(cache_dict, dirpath):
kwargs['logfunc'] = lambda msg: stderr.write(msg + '\n')
elif _class is Caches.Disk:
- kwargs['path'] = realpath(pathjoin(dirpath, cache_dict['path']))
+ parsed_dir = urlparse(dirpath)
+ parsed_path = urlparse(cache_dict['path'])
+
+ if parsed_path.scheme not in ('file', ''):
+ raise Core.KnownUnknown('Disk cache path must be a local file path, absolute or "file://", not "%s".' % cache_dict['path'])
+
+ if parsed_dir.scheme not in ('file', '') and parsed_path.scheme != 'file':
+ raise Core.KnownUnknown('Disk cache path must start with "file://" with a remote configuration ("%s" relative to %s)' % (cache_dict['path'], dirpath))
+
+ if parsed_path.scheme == 'file':
+ # file:// is an absolute local reference for the disk cache.
+ diskpath = parsed_path.path
+
+ elif parsed_dir.scheme == 'file':
+ # file:// is an absolute local reference for the directory.
+ diskpath = urljoin(parsed_dir.path, parsed_path.path)
+
+ else:
+ # nothing has a scheme, it's probably just a bunch of
+ # dumb local paths, so let's see what happens next.
+ diskpath = pathjoin(dirpath, cache_dict['path'])
+
+ kwargs['path'] = diskpath
if cache_dict.has_key('umask'):
kwargs['umask'] = int(cache_dict['umask'], 8)
View
@@ -4,4 +4,4 @@ import os
import TileStache
if __name__ == '__main__':
- TileStache.cgiHandler(os.environ, 'http://10.211.55.4/~migurski/TileStache/tilestache.cfg', debug=True)
+ TileStache.cgiHandler(os.environ, 'tilestache.cfg', debug=True)

0 comments on commit 6e0d99a

Please sign in to comment.