Mercurial > piecrust2
comparison piecrust/data/linker.py @ 1079:00a0a65d08e6
data: Fix debug rendering of the family data.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Thu, 15 Feb 2018 21:15:30 -0800 |
parents | f6b975db2545 |
children | 1a214de1e1f7 |
comparison
equal
deleted
inserted
replaced
1078:a6618fdab37e | 1079:00a0a65d08e6 |
---|---|
1 import logging | 1 import logging |
2 from piecrust.data.paginationdata import PaginationData | 2 from piecrust.data.paginationdata import PaginationData |
3 from piecrust.sources.base import ( | 3 from piecrust.sources.base import ( |
4 REL_PARENT_GROUP, REL_LOGICAL_PARENT_ITEM, REL_LOGICAl_CHILD_GROUP) | 4 REL_PARENT_GROUP, REL_LOGICAL_PARENT_ITEM, REL_LOGICAL_CHILD_GROUP) |
5 | 5 |
6 | 6 |
7 logger = logging.getLogger(__name__) | 7 logger = logging.getLogger(__name__) |
8 | 8 |
9 | 9 |
14 """ A template-exposed data class that lets the user navigate the | 14 """ A template-exposed data class that lets the user navigate the |
15 logical hierarchy of pages in a page source. | 15 logical hierarchy of pages in a page source. |
16 """ | 16 """ |
17 debug_render = ['parent', 'ancestors', 'siblings', 'children', 'root', | 17 debug_render = ['parent', 'ancestors', 'siblings', 'children', 'root', |
18 'forpath'] | 18 'forpath'] |
19 debug_render_invoke = ['parent', 'ancestors', 'siblings', 'children', | 19 debug_render_invoke = ['ancestors', 'siblings', 'children'] |
20 'root'] | |
21 debug_render_redirect = { | 20 debug_render_redirect = { |
22 'ancestors': '_debugRenderAncestors', | 21 'ancestors': '_debugRenderAncestors', |
23 'siblings': '_debugRenderSiblings', | 22 'siblings': '_debugRenderSiblings', |
24 'children': '_debugRenderChildren', | 23 'children': '_debugRenderChildren'} |
25 'root': '_debugRenderRoot'} | |
26 | 24 |
27 def __init__(self, source, content_item): | 25 def __init__(self, source, content_item): |
28 self._source = source | 26 self._source = source |
29 self._content_item = content_item | 27 self._content_item = content_item |
30 | 28 |
80 for i in self._getAllSiblings(): | 78 for i in self._getAllSiblings(): |
81 if not i.is_group: | 79 if not i.is_group: |
82 ipage = app.getPage(src, i) | 80 ipage = app.getPage(src, i) |
83 ipage_data = self._makePageData(ipage) | 81 ipage_data = self._makePageData(ipage) |
84 sibs.append(ipage_data) | 82 sibs.append(ipage_data) |
83 return sibs | |
84 | |
85 @property | |
86 def siblings_all(self): | |
87 src = self._source | |
88 app = src.app | |
89 sibs = [] | |
90 for i in self._getAllSiblings(): | |
91 if not i.is_group: | |
92 ipage = app.getPage(src, i) | |
93 ipage_data = self._makePageData(ipage) | |
94 sibs.append(ipage_data) | |
85 else: | 95 else: |
86 sibs.append(self._makeGroupData(i)) | 96 sibs.append(self._makeGroupData(i)) |
87 return sibs | 97 return sibs |
88 | 98 |
89 @property | 99 @property |
100 ipage = app.getPage(src, i) | 110 ipage = app.getPage(src, i) |
101 childs.append(self._makePageData(ipage)) | 111 childs.append(self._makePageData(ipage)) |
102 return childs | 112 return childs |
103 | 113 |
104 @property | 114 @property |
105 def children_and_groups(self): | 115 def children_all(self): |
106 src = self._source | 116 src = self._source |
107 app = src.app | 117 app = src.app |
108 childs = [] | 118 childs = [] |
109 for i in self._getAllChildren(): | 119 for i in self._getAllChildren(): |
110 if not i.is_group: | 120 if not i.is_group: |
147 return self._siblings | 157 return self._siblings |
148 | 158 |
149 def _getAllChildren(self): | 159 def _getAllChildren(self): |
150 if self._children is None: | 160 if self._children is None: |
151 child_group = self._source.getRelatedContents( | 161 child_group = self._source.getRelatedContents( |
152 self._content_item, REL_LOGICAl_CHILD_GROUP) | 162 self._content_item, REL_LOGICAL_CHILD_GROUP) |
153 if child_group is not None: | 163 if child_group is not None: |
154 self._children = list( | 164 self._children = list( |
155 self._source.getContents(child_group)) | 165 self._source.getContents(child_group)) |
156 else: | 166 else: |
157 self._children = [] | 167 self._children = [] |