comparison piecrust/data/linker.py @ 590:3cca1f6bd610

debug: Fix how the linker shows children/siblings/etc. in the debug window.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 17 Jan 2016 23:08:40 -0800
parents 48fcdd967212
children 4850f8c21b6e
comparison
equal deleted inserted replaced
589:9650638e504d 590:3cca1f6bd610
13 """ Entry template data to get access to related pages from a given 13 """ Entry template data to get access to related pages from a given
14 root page. 14 root page.
15 """ 15 """
16 debug_render = ['parent', 'ancestors', 'siblings', 'children', 'root', 16 debug_render = ['parent', 'ancestors', 'siblings', 'children', 'root',
17 'forpath'] 17 'forpath']
18 debug_render_invoke = ['parent', 'siblings', 'children'] 18 debug_render_invoke = ['parent', 'ancestors', 'siblings', 'children',
19 'root']
20 debug_render_redirect = {
21 'ancestors': '_debugRenderAncestors',
22 'siblings': '_debugRenderSiblings',
23 'children': '_debugRenderChildren',
24 'root': '_debugRenderRoot'}
19 25
20 def __init__(self, source, page_path): 26 def __init__(self, source, page_path):
21 self._source = source 27 self._source = source
22 self._root_page_path = page_path 28 self._root_page_path = page_path
23 self._linker = None 29 self._linker = None
81 return 87 return
82 88
83 dir_path = self._source.getDirpath(self._root_page_path) 89 dir_path = self._source.getDirpath(self._root_page_path)
84 self._linker = Linker(self._source, dir_path, 90 self._linker = Linker(self._source, dir_path,
85 root_page_path=self._root_page_path) 91 root_page_path=self._root_page_path)
92
93 def _debugRenderAncestors(self):
94 return [i.name for i in self.ancestors]
95
96 def _debugRenderSiblings(self):
97 return [i.name for i in self.siblings]
98
99 def _debugRenderChildren(self):
100 return [i.name for i in self.children]
101
102 def _debugRenderRoot(self):
103 r = self.root
104 if r is not None:
105 return r.name
106 return None
86 107
87 108
88 class LinkedPageData(PaginationData): 109 class LinkedPageData(PaginationData):
89 """ Class whose instances get returned when iterating on a `Linker` 110 """ Class whose instances get returned when iterating on a `Linker`
90 or `RecursiveLinker`. It's just like what gets usually returned by 111 or `RecursiveLinker`. It's just like what gets usually returned by