| 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 = ( |