Skip to content

Commit

Permalink
Merge 71d9cb4 into 47ac2d4
Browse files Browse the repository at this point in the history
  • Loading branch information
mhl committed Sep 5, 2017
2 parents 47ac2d4 + 71d9cb4 commit 606157e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# Build on Travis's container-based infrastructure, which starts builds
# much faster:
sudo: false
sudo: required

language: python
python:
- "2.7"
# command to install dependencies
services:
- elasticsearch
- rabbitmq
before_install:
- curl -O https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.4.5.deb && sudo dpkg -i --force-confnew elasticsearch-1.4.5.deb && sudo service elasticsearch restart
install:
- pip install -r requirements.txt
- pip install psycopg2
Expand All @@ -17,7 +18,7 @@ install:
before_script:
- psql -c 'create database writeit;' -U postgres
script:
- coverage run --source=nuntium,contactos,mailit manage.py test nuntium contactos mailit
- coverage run --source=nuntium,contactos,mailit,instance manage.py test nuntium contactos mailit instance
- coverage report -m
after_script:
- coveralls --verbose
Expand Down
16 changes: 12 additions & 4 deletions writeit/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@ def process_request(self, request):
self.tls.subdomain = None

def process_response(self, request, response):
# Unset the subdomain in thread-local storage on the way back
# up the middleware processing, just before returning the
# response to the browser.
self.tls.subdomain = None
# Remove the subdomain attribute from thread-local storage on
# the way back up the middleware processing, just before
# returning the response to the browser. This looks like it
# shouldn't make any difference (since the subdomain attribute
# is created again on each process_request) but in fact it
# does for tests: if the subdomain attribute still exists in
# the thread-local storage, tests that use templates outside
# of HTTP requests might pass when they should fail.
try:
delattr(self.tls, 'subdomain')
except AttributeError:
pass
return response
5 changes: 4 additions & 1 deletion writeit/template_loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ def get_template_sources(self, template_name, template_dirs=None):
Any paths that don't lie inside one of the template dirs are excluded
from the result set, for security reasons.
"""
subdomain = SubdomainInThreadLocalStorageMiddleware.tls.subdomain
try:
subdomain = SubdomainInThreadLocalStorageMiddleware.tls.subdomain
except AttributeError:
return
if not subdomain:
return
if not template_dirs:
Expand Down

0 comments on commit 606157e

Please sign in to comment.