move (non-api) clients (inc redis) from app/__init__.py to extensions

when clients are defined in app/__init__.py, it increases the chance of 
cyclical imports. By moving module level client singletons out to a 
separate extensions file, we stop cyclical imports, but keep the same 
code flow - the clients are still initialised in `create_app` in 
`__init__.py`.

The redis client in particular is no longer separate - previously redis 
was set up on the `NotifyAdminAPIClient` base class, but now there's one 
singleton in `app.extensions`. This was done so that we can access redis 
from outside of the existing clients.
This commit is contained in:
Leo Hemsted
2019-02-14 14:25:31 +00:00
parent 51e56614c0
commit f6367f2278
15 changed files with 64 additions and 55 deletions

View File

@@ -1,3 +1,4 @@
from app.extensions import redis_client
from app.notify_client import NotifyAdminAPIClient, cache
@@ -35,7 +36,7 @@ class TemplateFolderAPIClient(NotifyAdminAPIClient):
})
if template_ids:
self.redis_client.delete(*map(
redis_client.delete(*map(
'template-{}-version-None'.format,
template_ids,
))