Skip to content

Commit

Permalink
cache: Call template.get_default_value when view is missing
Browse files Browse the repository at this point in the history
This matches the behaviour of view.get(template)
  • Loading branch information
iamkroot committed May 16, 2022
1 parent 98e4982 commit da6c598
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions confuse/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from . import templates
from .core import ROOT_NAME, Configuration, ConfigView, RootView, Subview
from .exceptions import NotFoundError


class CachedHandle(object):
Expand All @@ -27,7 +26,8 @@ def get(self):
invalidated.
"""
if self.value is self._MISSING:
raise NotFoundError("The cached handle doesn't have a valid view")
# will raise a NotFoundError if no default value was provided
self.value = templates.as_template(self.template).get_default_value()
if self.value is self._INVALID:
self.value = self.view.get(self.template)
return self.value
Expand Down

0 comments on commit da6c598

Please sign in to comment.