From 45d1e5cd0e4fb70f3fd643fad20a53e58f8f7551 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Thu, 23 Apr 2015 07:29:55 +1200 Subject: [PATCH] Example websocket key for mock renders --- libpathod/app.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/libpathod/app.py b/libpathod/app.py index a6853ad44..aec3d95fd 100644 --- a/libpathod/app.py +++ b/libpathod/app.py @@ -7,6 +7,8 @@ from . import version, language, utils from netlib import http_uastrings logging.basicConfig(level="DEBUG") +EXAMPLE_HOST = "example.com" +EXAMPLE_WEBSOCKET_KEY = "examplekey" def make_app(noapi, debug): @@ -142,20 +144,25 @@ def make_app(noapi, debug): return render(template, False, **args) s = cStringIO.StringIO() + + set = copy.copy(app.config["pathod"].settings) + set.request_host = EXAMPLE_HOST + set.websocket_key = EXAMPLE_WEBSOCKET_KEY + safe = r.preview_safe() err, safe = app.config["pathod"].check_policy( safe, - app.config["pathod"].settings + set ) if err: args["error"] = err return render(template, False, **args) if is_request: - set = copy.copy(app.config["pathod"].settings) - set.request_host = "example.com" + set.request_host = EXAMPLE_HOST language.serve(safe, s, set) else: - language.serve(safe, s, app.config["pathod"].settings) + set.websocket_key = EXAMPLE_WEBSOCKET_KEY + language.serve(safe, s, set) args["output"] = utils.escape_unprintables(s.getvalue()) return render(template, False, **args)