From fae270a1d6f544a3be4bbdad0da0ef160b2a8a24 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Mon, 4 Feb 2019 17:26:32 +0100 Subject: [PATCH] Make sure the cache is ensured before manipulating it --- openslides/utils/cache.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/openslides/utils/cache.py b/openslides/utils/cache.py index 87b4945aa..0761867e6 100644 --- a/openslides/utils/cache.py +++ b/openslides/utils/cache.py @@ -133,6 +133,11 @@ class ElementCache: Returns the new generated change_id. """ + if not self.ensured: + raise RuntimeError( + "Call element_cache.ensure_cache before changing elements." + ) + deleted_elements = [] changed_elements = [] for element_id, data in elements.items(): @@ -265,6 +270,11 @@ class ElementCache: # If the restricted_data_cache is not used, there is nothing to do return + if not self.ensured: + raise RuntimeError( + "Call element_cache.ensure_cache before updating restricted data." + ) + # Try to write a special key. # If this succeeds, there is noone else currently updating the cache. # TODO: Make a timeout. Else this could block forever