mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 21:13:36 +00:00
Fixes #2665. Regenerated by tabbott with `lint --fix` after a rebase and change in parameters. Note from tabbott: In a few cases, this converts technical debt in the form of unsorted imports into different technical debt in the form of our largest files having very long, ugly import sequences at the start. I expect this change will increase pressure for us to split those files, which isn't a bad thing. Signed-off-by: Anders Kaseorg <anders@zulip.com>
29 lines
921 B
Python
29 lines
921 B
Python
import logging
|
|
from typing import Any
|
|
|
|
from django.apps import AppConfig
|
|
from django.conf import settings
|
|
from django.core.cache import cache
|
|
from django.db.models.signals import post_migrate
|
|
|
|
|
|
def flush_cache(sender: AppConfig, **kwargs: Any) -> None:
|
|
logging.info("Clearing memcached cache after migrations")
|
|
cache.clear()
|
|
|
|
|
|
class ZerverConfig(AppConfig):
|
|
name: str = "zerver"
|
|
|
|
def ready(self) -> None:
|
|
# We import zerver.signals here for the side effect of
|
|
# registering the user_logged_in signal receiver. This import
|
|
# needs to be here (rather than e.g. at top-of-file) to avoid
|
|
# running that code too early in Django's setup process, but
|
|
# in any case, this is an intentionally unused import.
|
|
import zerver.signals
|
|
zerver.signals
|
|
|
|
if settings.POST_MIGRATION_CACHE_FLUSHING:
|
|
post_migrate.connect(flush_cache, sender=self)
|