Mercurial > piecrust2
comparison piecrust/sources/autoconfig.py @ 1052:f8572df0756e
serve: Fix crash with autoconfig source pages when serving.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 28 Jan 2018 21:21:32 -0800 |
parents | 8adc27285d93 |
children | 75f1b4460491 |
comparison
equal
deleted
inserted
replaced
1051:971b4d67e82a | 1052:f8572df0756e |
---|---|
101 | 101 |
102 for dirpath, dirnames, filenames in os.walk(self.fs_endpoint_path): | 102 for dirpath, dirnames, filenames in os.walk(self.fs_endpoint_path): |
103 for f in filenames: | 103 for f in filenames: |
104 slug, _ = os.path.splitext(f) | 104 slug, _ = os.path.splitext(f) |
105 if slug == route_slug: | 105 if slug == route_slug: |
106 metadata = self._createItemMetadata(path) | |
106 path = os.path.join(dirpath, f) | 107 path = os.path.join(dirpath, f) |
107 rel_path = os.path.relpath(path, self.fs_endpoint_path) | 108 rel_path = os.path.relpath(path, self.fs_endpoint_path) |
108 config = self._extractConfigFragment(rel_path) | 109 config = self._extractConfigFragment(rel_path) |
109 metadata = {'slug': slug, 'config': config} | 110 metadata.setdefault('config', {}).update(config) |
110 return ContentItem(path, metadata) | 111 return ContentItem(path, metadata) |
111 return None | 112 return None |
112 | 113 |
113 def _makeSlug(self, path): | 114 def _makeSlug(self, path): |
114 slug = super()._makeSlug(path) | 115 slug = super()._makeSlug(path) |
168 found = True | 169 found = True |
169 break | 170 break |
170 if not found: | 171 if not found: |
171 return None | 172 return None |
172 | 173 |
174 metadata = self._createItemMetadata(path) | |
173 rel_path = os.path.relpath(path, self.fs_endpoint_path) | 175 rel_path = os.path.relpath(path, self.fs_endpoint_path) |
174 config = self._extractConfigFragment(rel_path) | 176 config = self._extractConfigFragment(rel_path) |
175 metadata = {'slug': uri_path, 'config': config} | 177 metadata.setdefault('config', {}).update(config) |
176 return ContentItem(path, metadata) | 178 return ContentItem(path, metadata) |
177 | 179 |
178 def getSorterIterator(self, it): | 180 def getSorterIterator(self, it): |
179 accessor = self.getSettingAccessor() | 181 accessor = self.getSettingAccessor() |
180 return OrderTrailSortIterator(it, self.setting_name + '_trail', | 182 return OrderTrailSortIterator(it, self.setting_name + '_trail', |