From eb43291b3c061c654dc93c26e924ca3cd0210b61 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Wed, 25 Jul 2012 12:49:22 +1200 Subject: Note that pauses are skipped during previews. --- libpathod/app.py | 5 +++-- libpathod/rparse.py | 4 +++- libpathod/templates/request_preview.html | 4 ++++ libpathod/templates/response_preview.html | 4 ++++ 4 files changed, 14 insertions(+), 3 deletions(-) (limited to 'libpathod') diff --git a/libpathod/app.py b/libpathod/app.py index c1fb670f..ebcf0369 100644 --- a/libpathod/app.py +++ b/libpathod/app.py @@ -93,7 +93,8 @@ def _preview(is_request): spec = spec, section = "main", syntaxerror = None, - error = None + error = None, + pauses = None ) if not spec.strip(): args["error"] = "Can't parse an empty spec." @@ -113,7 +114,7 @@ def _preview(is_request): return render(template, **args) s = cStringIO.StringIO() - r.preview_safe() + args["pauses"] = r.preview_safe() if is_request: r.serve(s, check=app.config["pathod"].check_size, host="example.com") diff --git a/libpathod/rparse.py b/libpathod/rparse.py index ea12185b..1a615950 100644 --- a/libpathod/rparse.py +++ b/libpathod/rparse.py @@ -533,9 +533,11 @@ class Message: def preview_safe(self): """ - Modify this message to be safe for previews. + Modify this message to be safe for previews. Returns a list of elided actions. """ + pauses = [i for i in self.actions if i[1] == "pause"] self.actions = [i for i in self.actions if i[1] != "pause"] + return pauses def effective_length(self, actions): """ diff --git a/libpathod/templates/request_preview.html b/libpathod/templates/request_preview.html index eaf78898..40f7771e 100644 --- a/libpathod/templates/request_preview.html +++ b/libpathod/templates/request_preview.html @@ -17,6 +17,10 @@
{{ output }}
+ {% if pauses %} +

Note: pauses are skipped when generating previews!

+ {% endif %} + {% endif %} {% include "request_previewform.html" %} {% endblock %} diff --git a/libpathod/templates/response_preview.html b/libpathod/templates/response_preview.html index 2e1abcf4..dd05e021 100644 --- a/libpathod/templates/response_preview.html +++ b/libpathod/templates/response_preview.html @@ -17,6 +17,10 @@
{{ output }}
+ {% if pauses %} +

Note: pauses are skipped when generating previews!

+ {% endif %} + {% endif %} {% include "response_previewform.html" %} {% endblock %} -- cgit v1.2.3