Browse Source

Fix for _init_cache and _load_source

master
Dirk Alders 3 months ago
parent
commit
b73dbd67ce
1 changed files with 10 additions and 3 deletions
  1. 10
    3
      __init__.py

+ 10
- 3
__init__.py View File

153
     def _init_cache(self):
153
     def _init_cache(self):
154
         load_cache = self._load_cache()
154
         load_cache = self._load_cache()
155
         uid = self._source_instance.uid() != self._uid()
155
         uid = self._source_instance.uid() != self._uid()
156
-        data_version = self._source_instance.data_version() > self._data_version()
157
-        storage_version = self._storage_version() != self.STORAGE_VERSION
156
+        try:
157
+            data_version = self._source_instance.data_version() > self._data_version()
158
+        except TypeError:
159
+            data_version = True
160
+        try:
161
+            storage_version = self._storage_version() != self.STORAGE_VERSION
162
+        except TypeError:
163
+            storage_version = True
158
         #
164
         #
159
         if not load_cache or uid or data_version or storage_version:
165
         if not load_cache or uid or data_version or storage_version:
160
             if self._uid() is not None and uid:
166
             if self._uid() is not None and uid:
188
         logger.debug('%s Loading all data from source - %s', self.LOG_PREFIX, repr(self._source_instance.keys()))
194
         logger.debug('%s Loading all data from source - %s', self.LOG_PREFIX, repr(self._source_instance.keys()))
189
         for key in self._source_instance.keys():
195
         for key in self._source_instance.keys():
190
             val = self._source_instance.get(key)
196
             val = self._source_instance.get(key)
191
-            self._cached_props[self._key_filter(key)] = val
197
+            self._cached_props[self.DATA_TAG][self._key_filter(key)] = val
198
+            self._cached_props[self.AGE_TAG][self._key_filter(key)] = int(time.time())
192
 
199
 
193
     def _save_cache(self):
200
     def _save_cache(self):
194
         with open(self._cache_filename, 'wb') as fh:
201
         with open(self._cache_filename, 'wb') as fh:

Loading…
Cancel
Save