-
-
Notifications
You must be signed in to change notification settings - Fork 711
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redesigned register_output_renderer plugin hook, closes #581
- Loading branch information
Showing
8 changed files
with
202 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from datasette import hookimpl | ||
import json | ||
|
||
|
||
def render_test_all_parameters( | ||
datasette, columns, rows, sql, query_name, database, table, request, view_name, data | ||
): | ||
headers = {} | ||
for custom_header in request.args.getlist("header") or []: | ||
key, value = custom_header.split(":") | ||
headers[key] = value | ||
return { | ||
"body": json.dumps( | ||
{ | ||
"datasette": datasette, | ||
"columns": columns, | ||
"rows": rows, | ||
"sql": sql, | ||
"query_name": query_name, | ||
"database": database, | ||
"table": table, | ||
"request": request, | ||
"view_name": view_name, | ||
}, | ||
default=repr, | ||
), | ||
"content_type": request.args.get("content_type", "text/plain"), | ||
"status_code": int(request.args.get("status_code", 200)), | ||
"headers": headers, | ||
} | ||
|
||
|
||
def render_test_no_parameters(): | ||
return {"body": "Hello"} | ||
|
||
|
||
@hookimpl | ||
def register_output_renderer(datasette): | ||
return [ | ||
{"extension": "testall", "render": render_test_all_parameters}, | ||
{"extension": "testnone", "callback": render_test_no_parameters}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters