migurski/TileStache — Issue #25: Exception when using new Cache Control header on 1.24.0
Author: andrew-blake
Created: 2012-01-30 23:27:13+00:00
State: open

I'm experiencing an exception using the latest version (1.24.0).

```python
Error on request:
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/Werkzeug-0.8.2-py2.6.egg/werkzeug/serving.py", line 159, in run_wsgi
execute(app)
File "/usr/local/lib/python2.6/dist-packages/Werkzeug-0.8.2-py2.6.egg/werkzeug/serving.py", line 146, in execute
application_iter = app(environ, start_response)
File "/ebs/data/tilestache/dev/TileStache/__init__.py", line 353, in __call__
return self._response(start_response, '200 OK', str(content), mimetype, allowed_origin, max_cache_age, request_layer)
File "/ebs/data/tilestache/dev/TileStache/__init__.py", line 364, in _response
expires = datetime.utcnow() + timedelta(seconds=layer.max_cache_age)
NameError: global name 'layer' is not defined
```

A simple fix is to just pass in the request_layer from the caller.

```python
return self._response(start_response, '200 OK', str(content), mimetype, allowed_origin, max_cache_age, request_layer)

def _response(self, start_response, code, content='', mimetype='text/plain', allowed_origin='', max_cache_age=None, layer = None):
```