models: Move flush_per_request_caches after cache definitions.

This will work around https://bugs.python.org/issue34939 when we
convert the type comment to a Python 3.6 style annotation.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg 2020-04-21 16:27:39 -07:00 committed by Tim Abbott
parent f8c95cda51
commit af1aef9b39
1 changed files with 6 additions and 6 deletions

View File

@ -99,12 +99,6 @@ def get_display_recipient(recipient: 'Recipient') -> DisplayRecipientT:
recipient.type_id
)
def flush_per_request_caches() -> None:
global per_request_display_recipient_cache
per_request_display_recipient_cache = {}
global per_request_realm_filters_cache
per_request_realm_filters_cache = {}
def get_realm_emoji_cache_key(realm: 'Realm') -> str:
return 'realm_emoji:%s' % (realm.id,)
@ -720,6 +714,12 @@ def flush_realm_filter(sender: Any, **kwargs: Any) -> None:
post_save.connect(flush_realm_filter, sender=RealmFilter)
post_delete.connect(flush_realm_filter, sender=RealmFilter)
def flush_per_request_caches() -> None:
global per_request_display_recipient_cache
per_request_display_recipient_cache = {}
global per_request_realm_filters_cache
per_request_realm_filters_cache = {}
# The Recipient table is used to map Messages to the set of users who
# received the message. It is implemented as a set of triples (id,
# type_id, type). We have 3 types of recipients: Huddles (for group