comparison piecrust/serving/server.py @ 515:16e705c58cae

internal: Improve handling of taxonomy term slugification. This paves the way to bring slugification options like transliteration to PieCrust. This change mostly makes sure we use one-way slugification, which means, for serving/previewing, we need to slugify each page's terms to compare to the stuff captured from the URL. It also simplifies things a bit in the code.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 26 Jul 2015 23:16:15 -0700
parents 64e1cd71b30b
children c7e8b4a5afe3
comparison
equal deleted inserted replaced
514:c9c305645e5f 515:16e705c58cae
319 taxonomy = app.getTaxonomy(route.taxonomy_name) 319 taxonomy = app.getTaxonomy(route.taxonomy_name)
320 route_terms = route_metadata.get(taxonomy.term_name) 320 route_terms = route_metadata.get(taxonomy.term_name)
321 if route_terms is None: 321 if route_terms is None:
322 return None 322 return None
323 323
324 tax_terms = route.getTaxonomyTerms(route_metadata)
325 taxonomy_info = (taxonomy, tax_terms)
326
324 tax_page_ref = taxonomy.getPageRef(source) 327 tax_page_ref = taxonomy.getPageRef(source)
325 factory = tax_page_ref.getFactory() 328 factory = tax_page_ref.getFactory()
326 tax_terms = route.unslugifyTaxonomyTerm(route_terms)
327 route_metadata[taxonomy.term_name] = tax_terms
328 taxonomy_info = (taxonomy, tax_terms)
329 329
330 # Build the page. 330 # Build the page.
331 page = factory.buildPage() 331 page = factory.buildPage()
332 # We force the rendering of the page because it could not have 332 # We force the rendering of the page because it could not have
333 # changed, but include pages that did change. 333 # changed, but include pages that did change.
334 qp = QualifiedPage(page, route, route_metadata) 334 qp = QualifiedPage(page, route, route_metadata)
335 render_ctx = PageRenderingContext(qp, 335 render_ctx = PageRenderingContext(qp,
336 page_num=page_num, 336 page_num=page_num,
337 force_render=True) 337 force_render=True)
338 if taxonomy_info is not None: 338 if taxonomy_info is not None:
339 taxonomy, tax_terms = taxonomy_info 339 _, tax_terms = taxonomy_info
340 render_ctx.setTaxonomyFilter(taxonomy, tax_terms) 340 render_ctx.setTaxonomyFilter(tax_terms)
341 341
342 # See if this page is known to use sources. If that's the case, 342 # See if this page is known to use sources. If that's the case,
343 # just don't use cached rendered segments for that page (but still 343 # just don't use cached rendered segments for that page (but still
344 # use them for pages that are included in it). 344 # use them for pages that are included in it).
345 uri = qp.getUri() 345 uri = qp.getUri()