Mercurial > piecrust2
comparison piecrust/baking/baker.py @ 50:2fec3ee1298f
Properly override pages between realms.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Fri, 22 Aug 2014 23:41:17 -0700 |
parents | fce061f8c2ed |
children | 3471ffa059b2 |
comparison
equal
deleted
inserted
replaced
49:fce061f8c2ed | 50:2fec3ee1298f |
---|---|
77 bake_path.append(decoded_uri + '.html') | 77 bake_path.append(decoded_uri + '.html') |
78 | 78 |
79 return os.path.normpath(os.path.join(*bake_path)) | 79 return os.path.normpath(os.path.join(*bake_path)) |
80 | 80 |
81 def bake(self, factory, route, taxonomy_name=None, taxonomy_term=None): | 81 def bake(self, factory, route, taxonomy_name=None, taxonomy_term=None): |
82 page = factory.buildPage() | |
83 | |
84 pagination_filter = None | 82 pagination_filter = None |
85 custom_data = None | 83 custom_data = None |
86 if taxonomy_name and taxonomy_term: | 84 if taxonomy_name and taxonomy_term: |
87 # Must bake a taxonomy listing page... we'll have to add a | 85 # Must bake a taxonomy listing page... we'll have to add a |
88 # pagination filter for only get matching posts, and the output | 86 # pagination filter for only get matching posts, and the output |
108 uri = route.getUri({tax.term_name: slugified_term}) | 106 uri = route.getUri({tax.term_name: slugified_term}) |
109 else: | 107 else: |
110 # Normal page bake. | 108 # Normal page bake. |
111 uri = route.getUri(factory.metadata) | 109 uri = route.getUri(factory.metadata) |
112 | 110 |
111 override = self.record.getOverrideEntry(factory, uri) | |
112 if override is not None: | |
113 override_source = self.app.getSource(override.source_name) | |
114 if override_source.realm == factory.source.realm: | |
115 raise Exception( | |
116 "Page '%s' maps to URL '%s' but is overriden by page" | |
117 "'%s:%s'." % (factory.ref_spec, uri, | |
118 override.source_name, override.rel_path)) | |
119 logger.debug("'%s' [%s] is overriden by '%s:%s'. Skipping" % | |
120 (factory.ref_spec, uri, override.source_name, | |
121 override.rel_path)) | |
122 entry = BakeRecordPageEntry() | |
123 entry.path = factory.path | |
124 entry.rel_path = factory.rel_path | |
125 entry.source_name = factory.source.name | |
126 entry.was_overriden = True | |
127 | |
128 if self.record: | |
129 self.record.addEntry(entry) | |
130 | |
131 return entry | |
132 | |
113 cur_sub = 1 | 133 cur_sub = 1 |
114 has_more_subs = True | 134 has_more_subs = True |
135 page = factory.buildPage() | |
115 cur_record_entry = BakeRecordPageEntry(page) | 136 cur_record_entry = BakeRecordPageEntry(page) |
116 cur_record_entry.taxonomy_name = taxonomy_name | 137 cur_record_entry.taxonomy_name = taxonomy_name |
117 cur_record_entry.taxonomy_term = taxonomy_term | 138 cur_record_entry.taxonomy_term = taxonomy_term |
118 prev_record_entry = self.record.getPreviousEntry(page, taxonomy_name, | 139 prev_record_entry = self.record.getPreviousEntry(page, taxonomy_name, |
119 taxonomy_term) | 140 taxonomy_term) |
538 self.ctx.work_queue.task_done() | 559 self.ctx.work_queue.task_done() |
539 except Exception as ex: | 560 except Exception as ex: |
540 self.ctx.abort_event.set() | 561 self.ctx.abort_event.set() |
541 self.abort_exception = ex | 562 self.abort_exception = ex |
542 logger.debug("[%d] Critical error, aborting." % self.wid) | 563 logger.debug("[%d] Critical error, aborting." % self.wid) |
564 if self.ctx.app.debug: | |
565 logger.exception(ex) | |
543 break | 566 break |
544 | 567 |
545 def _unsafeRun(self, job): | 568 def _unsafeRun(self, job): |
546 start_time = time.clock() | 569 start_time = time.clock() |
547 | 570 |