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

Python: Model the Pyramid framework #16300

Merged
merged 9 commits into from May 14, 2024

Conversation

joefarebrother
Copy link
Contributor

@joefarebrother joefarebrother commented Apr 22, 2024

Adds models for the Pyramid framework - models view callables, Request and Response objects, and http redirects

Copy link
Member

@RasmusWL RasmusWL left a comment

Choose a reason for hiding this comment

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

Nice progress 👍 a few comments from following along the commits 😊

}

abstract class ViewCallable extends PotentialViewCallable, Http::Server::RequestHandler::Range {
override Parameter getARoutedParameter() { result = this.getRequestParameter() }
Copy link
Member

Choose a reason for hiding this comment

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

for a route like /hello/<name> that is handled by def handle_hello(request, name): ... the <name> is a routed parameter. I haven't looked at the pyramid docs whether this is something they do, but that's sort of what it's for.

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 don't think pyramid has parameters like that (instead name would be in a matchdict object on the request.
Should the request parameter be modeled as a remote flow source separately from this then?

Copy link
Member

Choose a reason for hiding this comment

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

Should the request parameter be modeled as a remote flow source separately from this then?

Yes please 👍

private class PotentialViewCallable extends Function {
PotentialViewCallable() {
this.getPositionalParameterCount() = 1 and
this.getArgName(0) = "request"
Copy link
Member

Choose a reason for hiding this comment

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

is there a hard requirement that the request parameter MUST be called request? or could it be named req as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Documentation suggests that it should:

View callables must, at a minimum, accept a single argument named request.

however empirical testing seems to show it can allow other names.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, let's include that in our tests, and let's change our modeling to handle that 👍

@joefarebrother joefarebrother marked this pull request as ready for review April 30, 2024 20:12
@joefarebrother joefarebrother requested a review from a team as a code owner April 30, 2024 20:12
@joefarebrother joefarebrother changed the title [Draft] Python: Model the Pyramid framework Python: Model the Pyramid framework Apr 30, 2024
Copy link
Member

@RasmusWL RasmusWL left a comment

Choose a reason for hiding this comment

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

Nice work 👍 I've seen your (internal only) discussion around whether we recognize any route setups without a request handler, and appreciate the additional tests you added 💪

@joefarebrother joefarebrother merged commit 027e5e7 into github:main May 14, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants