MCPcopy Create free account
hub / github.com/alephdata/aleph / ancestors

Method ancestors

aleph/model/document.py:48–65  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

46
47 @property
48 def ancestors(self):
49 if self.parent_id is None:
50 return []
51 key = cache.key("ancestors", self.id)
52 ancestors = cache.get_list(key)
53 if len(ancestors):
54 return ancestors
55 parent_key = cache.key("ancestors", self.parent_id)
56 ancestors = cache.get_list(parent_key)
57 if not len(ancestors):
58 ancestors = []
59 parent = Document.by_id(self.parent_id)
60 if parent is not None:
61 ancestors = parent.ancestors
62 ancestors.append(self.parent_id)
63 if self.model.is_a(model.get(self.SCHEMA_FOLDER)):
64 cache.set_list(key, ancestors, expires=cache.EXPIRE)
65 return ancestors
66
67 def update(self, data):
68 props = (

Callers

nothing calls this directly

Calls 5

keyMethod · 0.80
get_listMethod · 0.80
set_listMethod · 0.80
by_idMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected