+ def cache_key(self):
+ return self._generate_cache_key(self.id)
+
+ @classmethod
+ def value_to_list_on_cache_query(cls):
+ return 'id'
+
+ @classmethod
+ def infer_cache_key(cls, querydict):
+ try:
+ pk = [v for (k,v) in querydict.items() if k in ('pk', 'pk__exact', 'id', 'id__exact'
+ ) or k.endswith('_ptr__pk') or k.endswith('_ptr__id')][0]
+
+ return cls._generate_cache_key(pk)
+ except:
+ return None
+
+ def cache(self):
+ cache.set(self.cache_key(), self._as_dict(), 60 * 60)
+
+ def uncache(self):
+ cache.delete(self.cache_key())
+
+ def delete(self):
+ self.uncache()
+ self._set_query_cache_invalidation_timestamp()
+ super(BaseModel, self).delete()
+
+
+from user import User
+from node import Node, NodeRevision, NodeManager
+from action import Action