Mercurial > piecrust2
view piecrust/admin/views/mentions.py @ 1136:5f97b5b59dfe
bake: Optimize cache handling for the baking process.
- Get rid of the 2-level pipeline runs... handle a single set of passes.
- Go back to load/render segments/layout passes for pages.
- Add descriptions of what each job batch does.
- Improve the taxonomy pipeline so it doesn't re-bake terms that don't need
to be re-baked.
- Simplify some of the code.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 23 Apr 2018 21:47:49 -0700 |
parents | 8af2ea1f5c34 |
children |
line wrap: on
line source
import logging from flask import g, request, make_response, abort from ..blueprint import foodtruck_bp from piecrust.tasks.base import TaskManager logger = logging.getLogger(__name__) @foodtruck_bp.route('/webmention', methods=['POST']) def post_webmention(): # Basic validation of source/target. src_url = request.form.get('source') tgt_url = request.form.get('target') if not src_url or not tgt_url: logger.error("No source or target specified.") abort(400) if src_url.lower().rstrip('/') == tgt_url.lower().rstrip('/'): logger.error("Source and target are the same.") abort(400) # Create the task for handling this mention. pcapp = g.site.piecrust_app task_manager = TaskManager(pcapp) task_id = task_manager.createTask('mention', { 'source': src_url, 'target': tgt_url}) # Either run the task now in a background process (for cheap and simple # setups), or leave the task there to be picked up later when someone # runs the task queue eventually. wmcfg = pcapp.config.get('webmention') if not wmcfg.get('use_task_queue'): g.site.runTask(task_id) return make_response("Webmention queued.", 202, [])