diff --git a/src/webapp/models.py b/src/webapp/models.py index 1b51c1a65..702cf7b24 100644 --- a/src/webapp/models.py +++ b/src/webapp/models.py @@ -49,12 +49,17 @@ def __init__(self, data=None, timestamp=0, force_update=True, cache_lifetime=60* self.next_update = self.timestamp + self.cache_lifetime def should_update(self): + """Return True if we should update, either because we're past the next update time + or because force_update is True. + """ return self.force_update or not self.data or time.time() > self.next_update def try_again(self): + """Set the next update time to now + the retry delay.""" self.next_update = time.time() + self.retry_delay def update(self, data): + """Cache new data and set the next update time to now + the cache lifetime.""" self.data = data self.timestamp = time.time() self.next_update = self.timestamp + self.cache_lifetime