Skip to content

Commit

Permalink
Made it possible to instantiate WSGI server with a configuration obje…
Browse files Browse the repository at this point in the history
…ct instead of a file, bumped to version 1.7.3
  • Loading branch information
migurski committed Mar 17, 2011
1 parent 3ab787d commit 5a6d650
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2011-03-17: 1.7.3
- Made it possible to instantiate WSGI server with a configuration object instead of a file.

2011-01-31: 1.7.2
- Fixed json import to account for older Python versions, by checking for simplejson availability.

Expand Down
31 changes: 23 additions & 8 deletions TileStache/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,16 +217,31 @@ class WSGITileServer:
def __init__(self, config, autoreload=False):
""" Initialize a callable WSGI instance.
Required config parameter is a path to a configuration file.
Optional autoreload boolean parameter causes config to be re-read on each request.
Config parameter can be a file path string for a JSON configuration
file or a configuration object with 'cache', 'layers', and
'dirpath' properties.
Optional autoreload boolean parameter causes config to be re-read
on each request, applicable only when config is a JSON file.
"""
self.autoreload = autoreload
self.config_path = config

try:
self.config = parseConfigfile(config)
except Exception, e:
raise Core.KnownUnknown("Error loading Tilestache config file:\n%s" % str(e))
if type(config) in (str, unicode):
self.autoreload = autoreload
self.config_path = config

try:
self.config = parseConfigfile(config)
except Exception, e:
raise Core.KnownUnknown("Error loading Tilestache config file:\n%s" % str(e))

else:
assert hasattr(config, 'cache'), 'Configuration object must have a cache.'
assert hasattr(config, 'layers'), 'Configuration object must have layers.'
assert hasattr(config, 'dirpath'), 'Configuration object must have a dirpath.'

self.autoreload = False
self.config_path = None
self.config = config

def __call__(self, environ, start_response):
"""
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.7.2
1.7.3

0 comments on commit 5a6d650

Please sign in to comment.