2016-10-17 18:11:16 +02:00
|
|
|
import logging
|
2021-07-25 11:27:22 +02:00
|
|
|
from typing import Any, Optional
|
2016-10-17 18:11:16 +02:00
|
|
|
|
2017-11-16 00:50:28 +01:00
|
|
|
from django.apps import AppConfig
|
|
|
|
from django.conf import settings
|
|
|
|
from django.core.cache import cache
|
|
|
|
from django.db.models.signals import post_migrate
|
2017-01-30 23:19:38 +01:00
|
|
|
|
2020-06-11 00:54:34 +02:00
|
|
|
|
2021-07-25 11:27:22 +02:00
|
|
|
def flush_cache(sender: Optional[AppConfig], **kwargs: Any) -> None:
|
2016-10-17 18:11:16 +02:00
|
|
|
logging.info("Clearing memcached cache after migrations")
|
|
|
|
cache.clear()
|
|
|
|
|
|
|
|
|
|
|
|
class ZerverConfig(AppConfig):
|
python: Convert assignment type annotations to Python 3.6 style.
This commit was split by tabbott; this piece covers the vast majority
of files in Zulip, but excludes scripts/, tools/, and puppet/ to help
ensure we at least show the right error messages for Xenial systems.
We can likely further refine the remaining pieces with some testing.
Generated by com2ann, with whitespace fixes and various manual fixes
for runtime issues:
- invoiced_through: Optional[LicenseLedger] = models.ForeignKey(
+ invoiced_through: Optional["LicenseLedger"] = models.ForeignKey(
-_apns_client: Optional[APNsClient] = None
+_apns_client: Optional["APNsClient"] = None
- notifications_stream: Optional[Stream] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
- signup_notifications_stream: Optional[Stream] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
+ notifications_stream: Optional["Stream"] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
+ signup_notifications_stream: Optional["Stream"] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
- author: Optional[UserProfile] = models.ForeignKey('UserProfile', blank=True, null=True, on_delete=CASCADE)
+ author: Optional["UserProfile"] = models.ForeignKey('UserProfile', blank=True, null=True, on_delete=CASCADE)
- bot_owner: Optional[UserProfile] = models.ForeignKey('self', null=True, on_delete=models.SET_NULL)
+ bot_owner: Optional["UserProfile"] = models.ForeignKey('self', null=True, on_delete=models.SET_NULL)
- default_sending_stream: Optional[Stream] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
- default_events_register_stream: Optional[Stream] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
+ default_sending_stream: Optional["Stream"] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
+ default_events_register_stream: Optional["Stream"] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
-descriptors_by_handler_id: Dict[int, ClientDescriptor] = {}
+descriptors_by_handler_id: Dict[int, "ClientDescriptor"] = {}
-worker_classes: Dict[str, Type[QueueProcessingWorker]] = {}
-queues: Dict[str, Dict[str, Type[QueueProcessingWorker]]] = {}
+worker_classes: Dict[str, Type["QueueProcessingWorker"]] = {}
+queues: Dict[str, Dict[str, Type["QueueProcessingWorker"]]] = {}
-AUTH_LDAP_REVERSE_EMAIL_SEARCH: Optional[LDAPSearch] = None
+AUTH_LDAP_REVERSE_EMAIL_SEARCH: Optional["LDAPSearch"] = None
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-22 01:09:50 +02:00
|
|
|
name: str = "zerver"
|
2016-10-17 18:11:16 +02:00
|
|
|
|
2017-11-27 07:33:05 +01:00
|
|
|
def ready(self) -> None:
|
2022-09-24 06:50:42 +02:00
|
|
|
if settings.SENTRY_DSN: # nocoverage
|
|
|
|
from zproject.config import get_config
|
|
|
|
from zproject.sentry import setup_sentry
|
|
|
|
|
|
|
|
setup_sentry(settings.SENTRY_DSN, get_config("machine", "deploy_type", "development"))
|
|
|
|
|
2019-02-03 08:02:55 +01:00
|
|
|
# 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.
|
2023-04-04 01:42:32 +02:00
|
|
|
import zerver.signals # noqa: F401
|
2017-01-30 23:19:38 +01:00
|
|
|
|
2016-10-17 18:11:16 +02:00
|
|
|
if settings.POST_MIGRATION_CACHE_FLUSHING:
|
|
|
|
post_migrate.connect(flush_cache, sender=self)
|