Ver código fonte

Fix for _init_cache and _load_source

master
Dirk Alders 3 meses atrás
pai
commit
b73dbd67ce
1 arquivos alterados com 10 adições e 3 exclusões
  1. 10
    3
      __init__.py

+ 10
- 3
__init__.py Ver arquivo

@@ -153,8 +153,14 @@ class property_cache_pickle(object):
153 153
     def _init_cache(self):
154 154
         load_cache = self._load_cache()
155 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 165
         if not load_cache or uid or data_version or storage_version:
160 166
             if self._uid() is not None and uid:
@@ -188,7 +194,8 @@ class property_cache_pickle(object):
188 194
         logger.debug('%s Loading all data from source - %s', self.LOG_PREFIX, repr(self._source_instance.keys()))
189 195
         for key in self._source_instance.keys():
190 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 200
     def _save_cache(self):
194 201
         with open(self._cache_filename, 'wb') as fh:

Carregando…
Cancelar
Salvar