Skip to content
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

Change SQLAlchemy utility views to access the query internally. #227

Merged
merged 2 commits into from
Jun 2, 2015
Merged

Change SQLAlchemy utility views to access the query internally. #227

merged 2 commits into from
Jun 2, 2015

Conversation

inklesspen
Copy link
Contributor

This allows SELECT/EXPLAIN to be run for queries which have params that are not JSON-serializable.

Also, it's arguably a cleaner design.

Closes #222.

@@ -156,6 +156,7 @@ def sget(opt, default=None):
exc_history.eval_exc = intercept_exc == 'debug'

def toolbar_tween(request):
request.pdbt_id = hexlify(id(request))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this probably belongs lower. Probably just before where the toolbar is instantiated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

config.add_route('debugtoolbar.sql_select', '/sqlalchemy/sql_select')
config.add_route('debugtoolbar.sql_explain', '/sqlalchemy/sql_explain')
config.add_route('debugtoolbar.sql_select', '/{request_id}/sqlalchemy/sql_select')
config.add_route('debugtoolbar.sql_explain', '/{request_id}/sqlalchemy/sql_explain')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep the addon namespacing at the root of the url to avoid any weird ordering problems in the future. Considering moving the request_id to the end or middle or even as a query string arg next to the query_index?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meh, I guess we already have /{request_id}... I guess I'll retract that request.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could do /sqlalchemy/{request_id}/sql_select/{query_index}, if you like.

Given that both parameters are required to be able to do anything, I think they both belong in the route.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok let's formalize this and try to keep consistent.

/{request_id}/<panel_name>/...

So in this case it'd be /{request_id}/sqlalchemy/select/{query_index}.

So long as no one does /{request_id}/{another_placeholder} we won't have ambiguous routes that depend on panel include order.

This way the params don't have to be JSON-serializable.
@inklesspen
Copy link
Contributor Author

@mmerickel I believe I've resolved the routes to your satisfaction.

mmerickel added a commit that referenced this pull request Jun 2, 2015
Change SQLAlchemy utility views to access the query internally.
@mmerickel mmerickel merged commit a563580 into Pylons:master Jun 2, 2015
@mmerickel
Copy link
Member

Excellent work, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to SELECT/EXPLAIN from query with datetime in params
2 participants