mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 20:44:04 +00:00
- To avoid redefining migrate manage command is added new application configuration class which emit post_migration signal. This signal require models module inside application and defined AppConfig Instance as signal sender. Documentation here: https://docs.djangoproject.com/en/1.8/ref/signals/#post-migrate. - Add AppConf subclass to __init__ zerver app file to make apllication load it by default. Fixes #1084.
24 lines
617 B
Python
24 lines
617 B
Python
from __future__ import print_function
|
|
|
|
from django.apps import AppConfig
|
|
from django.db.models.signals import post_migrate
|
|
from django.core.cache import cache
|
|
from django.conf import settings
|
|
from typing import Any, Dict
|
|
|
|
import logging
|
|
|
|
def flush_cache(sender, **kwargs):
|
|
# type: (AppConfig, **Any) -> None
|
|
logging.info("Clearing memcached cache after migrations")
|
|
cache.clear()
|
|
|
|
|
|
class ZerverConfig(AppConfig):
|
|
name = "zerver" # type: str
|
|
|
|
def ready(self):
|
|
# type: () -> None
|
|
if settings.POST_MIGRATION_CACHE_FLUSHING:
|
|
post_migrate.connect(flush_cache, sender=self)
|