comparison piecrust/data/linker.py @ 440:32c7c2d219d2

performance: Refactor how data is managed to reduce copying. * Make use of `collections.abc.Mapping` to better identify things that are supposed to look like dictionaries. * Instead of handling "overlay" of data in a dict tree in each different data object, make all objects `Mapping`s and handle merging at a higher level with the new `MergedMapping` object. * Since this new object is read-only, remove the need for deep-copying of app and page configurations. * Split data classes into separate modules.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 28 Jun 2015 08:22:39 -0700
parents e7b865f8f335
children 48fcdd967212
comparison
equal deleted inserted replaced
439:c0700c6d9545 440:32c7c2d219d2
1 import logging 1 import logging
2 import collections 2 import collections
3 from piecrust.data.base import PaginationData, LazyPageConfigLoaderHasNoValue
4 from piecrust.data.iterators import PageIterator 3 from piecrust.data.iterators import PageIterator
4 from piecrust.data.pagedata import LazyPageConfigLoaderHasNoValue
5 from piecrust.data.paginationdata import PaginationData
5 from piecrust.sources.interfaces import IPaginationSource, IListableSource 6 from piecrust.sources.interfaces import IPaginationSource, IListableSource
6 7
7 8
8 logger = logging.getLogger(__name__) 9 logger = logging.getLogger(__name__)
9 10
101 self.is_self = page._linker_info.is_self 102 self.is_self = page._linker_info.is_self
102 self.is_dir = page._linker_info.is_dir 103 self.is_dir = page._linker_info.is_dir
103 self.is_page = True 104 self.is_page = True
104 self._child_linker = page._linker_info.child_linker 105 self._child_linker = page._linker_info.child_linker
105 106
106 self.mapLoader('*', self._linkerChildLoader) 107 self._mapLoader('*', self._linkerChildLoader)
107 108
108 @property 109 @property
109 def parent(self): 110 def parent(self):
110 if self._child_linker is not None: 111 if self._child_linker is not None:
111 return self._child_linker.parent 112 return self._child_linker.parent