-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Binary parameter handling for GeoDjango #2169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
fab74c3
Binary parameter handling for GeoDjango
f361a01
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] fefdb94
Update the checklist for: have added an item to the Pending section o…
bc395f0
Add DebugToolBarJSONDecoder class for better organization of code
eduzen 2713994
Fix tests for new DebugToolbarJSONDecoder
eduzen 9f9b888
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 217b3a5
Update tests/panels/test_sql_geodjango_fix.py
eduzen 361e84e
Address feedback
eduzen ee01ec4
pre-commit lint
eduzen 05acb9e
Update debug_toolbar/panels/sql/forms.py
eduzen de100bc
Apply suggestions from code review
eduzen 106e8b8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 5a3257b
feat: address feedback
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add DebugToolBarJSONDecoder class for better organization of code
- Loading branch information
commit bc395f0d85d1b5dc8cdd3361ecbb57858c740cf7
There are no files selected for viewing
This file contains hidden or 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,26 @@ | ||
| import base64 | ||
| import json | ||
|
|
||
|
|
||
| class DebugToolbarJSONDecoder(json.JSONDecoder): | ||
| """Custom JSON decoder that reconstructs binary data during parsing.""" | ||
|
|
||
| def decode(self, s): | ||
| """Override decode to apply reconstruction after parsing.""" | ||
| obj = super().decode(s) | ||
| return self._reconstruct_params(obj) | ||
|
|
||
| def _reconstruct_params(self, params): | ||
| """Reconstruct parameters, handling lists and dicts recursively.""" | ||
| if isinstance(params, list): | ||
| return [self._reconstruct_params(param) for param in params] | ||
| elif isinstance(params, dict): | ||
| if "__djdt_binary__" in params: | ||
| return base64.b64decode(params["__djdt_binary__"]) | ||
| else: | ||
| return { | ||
| key: self._reconstruct_params(value) | ||
| for key, value in params.items() | ||
| } | ||
| else: | ||
| return params | ||
|
tim-schilling marked this conversation as resolved.
Outdated
|
||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.