ciudadanointeligente / write-it

App to create and send messages to public persons. It's a component of POPLUS project.
poplus.org
GNU General Public License v3.0
38 stars 23 forks source link

Fix subdomain dependent template loading #1216

Closed mhl closed 7 years ago

mhl commented 7 years ago

Since Django 1.8 the subdomain-dependent template loading no longer worked, since the template directories were being cached once per worker, since EngineHandler.templates has the cached_property decorator.

It seems that a custom template loader would be a better way of arranging this subdomain-dependent template loading anyway, and that's the replacement method introduced in this pull request. Unfortunately, template loaders aren't passed the request object, so instead we're storing the subdomain in thread-local storage via some new middleware.

Fixes https://github.com/mysociety/alpaca/issues/64

Thanks to Matthew Somerville for his help in figuring out what was going wrong and possible solutions.

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 98.144% when pulling a916612d9b395768fea60fe101c2139dde150fc7 on fix-subdomain-dependent-templates into 085f1bbbd1cd9e998cc3a472a5cd2455356c4c33 on alpaca-rebased-django-1.8.

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 98.144% when pulling 47ac2d4421d53f4ab53d0e49d8912256feecaff3 on fix-subdomain-dependent-templates into 085f1bbbd1cd9e998cc3a472a5cd2455356c4c33 on alpaca-rebased-django-1.8.