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

request.url_vars helper property #822

Closed
simonw opened this issue Jun 9, 2020 · 2 comments
Closed

request.url_vars helper property #822

simonw opened this issue Jun 9, 2020 · 2 comments

Comments

@simonw
Copy link
Owner

simonw commented Jun 9, 2020

This example: https://github.com/simonw/datasette/blob/f5e79adf26d0daa3831e3fba022f1b749a9efdee/docs/plugins.rst#register_routes

from datasette.utils.asgi import Response
import html


async def hello_from(scope):
    name = scope["url_route"]["kwargs"]["name"]
    return Response.html("Hello from {}".format(
        html.escape(name)
    ))


@hookimpl
def register_routes():
    return [
        (r"^/hello-from/(?P<name>.*)$"), hello_from)
    ]

Would be nicer if you could easily get scope["url_route"]["kwargs"]["name"] directly from the request object, without looking at the scope.

@simonw simonw added this to the Datasette 0.44 milestone Jun 9, 2020
@simonw
Copy link
Owner Author

simonw commented Jun 9, 2020

Currently querystring parameters are accessed through request.args and POST variables through request.post_vars(). Would be good to have a name that was somewhat consistent with those.

@simonw
Copy link
Owner Author

simonw commented Jun 9, 2020

I'm leaning towards request.url_vars.

@simonw simonw changed the title request.url_params helper property request.url_vars helper property Jun 9, 2020
@simonw simonw closed this as completed in fac8e93 Jun 9, 2020
simonw added a commit that referenced this issue Jun 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant