From a4648418678572c9041889cb3b81c105937cda9f Mon Sep 17 00:00:00 2001 From: Nick Daly Date: Thu, 28 Jun 2012 00:34:08 -0500 Subject: [PATCH] Added escaped JSON output. --- ugly_hacks/santiago/protocols/https/templates/__init__.py | 0 .../santiago/protocols/https/templates/json/__init__.py | 0 .../santiago/protocols/https/templates/json/consumedHost.tmpl | 2 ++ .../protocols/https/templates/json/consumedService.tmpl | 2 ++ .../santiago/protocols/https/templates/json/consuming.tmpl | 3 ++- ugly_hacks/santiago/protocols/https/templates/json/escape.py | 4 ++++ .../santiago/protocols/https/templates/json/hostedClient.tmpl | 2 ++ .../protocols/https/templates/json/hostedService.tmpl | 2 ++ .../santiago/protocols/https/templates/json/hosting.tmpl | 2 ++ 9 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 ugly_hacks/santiago/protocols/https/templates/__init__.py create mode 100644 ugly_hacks/santiago/protocols/https/templates/json/__init__.py create mode 100644 ugly_hacks/santiago/protocols/https/templates/json/consumedHost.tmpl create mode 100644 ugly_hacks/santiago/protocols/https/templates/json/consumedService.tmpl create mode 100644 ugly_hacks/santiago/protocols/https/templates/json/escape.py create mode 100644 ugly_hacks/santiago/protocols/https/templates/json/hostedClient.tmpl create mode 100644 ugly_hacks/santiago/protocols/https/templates/json/hostedService.tmpl create mode 100644 ugly_hacks/santiago/protocols/https/templates/json/hosting.tmpl diff --git a/ugly_hacks/santiago/protocols/https/templates/__init__.py b/ugly_hacks/santiago/protocols/https/templates/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/ugly_hacks/santiago/protocols/https/templates/json/__init__.py b/ugly_hacks/santiago/protocols/https/templates/json/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/ugly_hacks/santiago/protocols/https/templates/json/consumedHost.tmpl b/ugly_hacks/santiago/protocols/https/templates/json/consumedHost.tmpl new file mode 100644 index 000000000..46aa8ab03 --- /dev/null +++ b/ugly_hacks/santiago/protocols/https/templates/json/consumedHost.tmpl @@ -0,0 +1,2 @@ +#from protocols.https.templates.json.escape import json_escape +$json_escape($services) diff --git a/ugly_hacks/santiago/protocols/https/templates/json/consumedService.tmpl b/ugly_hacks/santiago/protocols/https/templates/json/consumedService.tmpl new file mode 100644 index 000000000..7a1b1baa4 --- /dev/null +++ b/ugly_hacks/santiago/protocols/https/templates/json/consumedService.tmpl @@ -0,0 +1,2 @@ +#from protocols.https.templates.json.escape import json_escape +$json_escape($locations) \ No newline at end of file diff --git a/ugly_hacks/santiago/protocols/https/templates/json/consuming.tmpl b/ugly_hacks/santiago/protocols/https/templates/json/consuming.tmpl index 8c0c185ba..3d3f748a7 100644 --- a/ugly_hacks/santiago/protocols/https/templates/json/consuming.tmpl +++ b/ugly_hacks/santiago/protocols/https/templates/json/consuming.tmpl @@ -1 +1,2 @@ -$hosts +#from protocols.https.templates.json.escape import json_escape +$json_escape($hosts) diff --git a/ugly_hacks/santiago/protocols/https/templates/json/escape.py b/ugly_hacks/santiago/protocols/https/templates/json/escape.py new file mode 100644 index 000000000..ba672b03f --- /dev/null +++ b/ugly_hacks/santiago/protocols/https/templates/json/escape.py @@ -0,0 +1,4 @@ +import cgi, json + +def json_escape(x): + return [json.dumps(cgi.escape(y)) for y in x] diff --git a/ugly_hacks/santiago/protocols/https/templates/json/hostedClient.tmpl b/ugly_hacks/santiago/protocols/https/templates/json/hostedClient.tmpl new file mode 100644 index 000000000..46aa8ab03 --- /dev/null +++ b/ugly_hacks/santiago/protocols/https/templates/json/hostedClient.tmpl @@ -0,0 +1,2 @@ +#from protocols.https.templates.json.escape import json_escape +$json_escape($services) diff --git a/ugly_hacks/santiago/protocols/https/templates/json/hostedService.tmpl b/ugly_hacks/santiago/protocols/https/templates/json/hostedService.tmpl new file mode 100644 index 000000000..a9e7286ca --- /dev/null +++ b/ugly_hacks/santiago/protocols/https/templates/json/hostedService.tmpl @@ -0,0 +1,2 @@ +#from protocols.https.templates.json.escape import json_escape +$json_escape($locations) diff --git a/ugly_hacks/santiago/protocols/https/templates/json/hosting.tmpl b/ugly_hacks/santiago/protocols/https/templates/json/hosting.tmpl new file mode 100644 index 000000000..964ca9c90 --- /dev/null +++ b/ugly_hacks/santiago/protocols/https/templates/json/hosting.tmpl @@ -0,0 +1,2 @@ +#from protocols.https.templates.json.escape import json_escape +$json_escape($clients)