Skip to content

URLConf: fix support for subprojects #8327

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
wants to merge 1 commit into from
Closed

Conversation

stsewd
Copy link
Member

@stsewd stsewd commented Jul 7, 2021

We were always exposing the subproject part in the custom URLs, that means that we are only serving subprojects,
in our proxito URLs we get around that by marking that part as optional with regex.

Here I split the patter into one url patter for the main project and the other for subprojects (we could also maybe hack this to mark it as optional in the regex pattern).

Other couple of fixes I found along the way

  • The urlpattern will be used to generate both, subprojects and the main project url, we could end up generating urls like /subprojects/None/en/latest.
  • If the urlconf would start with $subproject/foo the proxied api endpoint would be generated like //_

There are still more things to fix, like:

  • Users would need to serve the main project from the subproject path (like if we have /sub/{subproject}, the main project would be served from /sub/en/latest), we could have two urlconfs, one for the main project and other for subprojects for further customization.
  • Infinite redirects
  • missing updates in our code to make use of the custom urlconf to generate the urls (like the ones from "view docs")
  • Possible collitions, a path could match something that shouldn't

I was also thinking we could go for another implementation.
Instead of relying on the url patterns and their regexes, we could have a catch all paths url pattern (/anything/that/isn't/the/proxied/api), then at the view level split the components (anything, that, 'isnt', 'the', 'proxied', 'api'), and use the information from the current project being served to identify each component (if the project is single version, what part is the version, the subproject, the language, etc). Like if the project doesn't have subprojects, we know that the projects part is part of the path, or if the project doesn't have a translation, etc (avoiding collisions like #8399). This is just an idea, and we wouldn't need to hack our middleware to make it work.

@ericholscher
Copy link
Member

I was also thinking we could go for another implementation.
Instead of relying on the url patterns and their regexes, we could have a catch all paths url pattern (/anything/that/isn't/the/proxied/api), then at the view level split the components (anything, that, 'isnt', 'the', 'proxied', 'api'), and use the information from the current project being served to identify each component (if the project is single version, what part is the version, the subproject, the language, etc). Like if the project doesn't have subprojects, we know that the projects part is part of the path, or if the project doesn't have a translation, etc (avoiding collisions like #8399). This is just an idea, and we wouldn't need to hack our middleware to make it work.

This sounds interesting, but it's non-trivial. We ran into a ton of issues with this in the past, but we might be able to create some better solutions here than we did previously. Knowing the list of languages, versions, and subprojects would make the list of possible URL's workable, but it definitely gets complex pretty fast.

We should probably think a bit more how to handle this, because I definitely don't love the current implementation, either :/

@ericholscher
Copy link
Member

@stsewd lets discuss this on a call? Perhaps tomorrow?

@stsewd
Copy link
Member Author

stsewd commented Aug 19, 2021

@stsewd lets discuss this on a call? Perhaps tomorrow?

just saw this p: but yeah, we can schedule a call

@stale
Copy link

stale bot commented Mar 2, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: stale Issue will be considered inactive soon label Mar 2, 2022
@stale stale bot closed this Apr 16, 2022
@ericholscher ericholscher added the Accepted Accepted issue on our roadmap label Apr 18, 2022
@ericholscher ericholscher reopened this Apr 18, 2022
@stale stale bot removed the Status: stale Issue will be considered inactive soon label Apr 18, 2022
@ericholscher
Copy link
Member

ericholscher commented Jun 21, 2022

@stsewd Adding this one to the roadmap, but let's discuss other possible approaches here, as you noted in the PR description.

stsewd added a commit that referenced this pull request Jul 11, 2022
@humitos
Copy link
Member

humitos commented Jul 13, 2022

This sounds interesting, but it's non-trivial. We ran into a ton of issues with this in the past, but we might be able to create some better solutions here than we did previously. Knowing the list of languages, versions, and subprojects would make the list of possible URL's workable, but it definitely gets complex pretty fast.

@stsewd @ericholscher isn't this exactly what the new unresolver does?

class UnresolverBase:

@stsewd
Copy link
Member Author

stsewd commented Jul 13, 2022

isn't this exactly what the new unresolver does?

The unresolver still uses django's urlconf, i.e, still tries to guess the project given the URL.

@stsewd
Copy link
Member Author

stsewd commented Aug 31, 2022

I'm closing this PR since we are moving forward with a new implementation for proxito.

@stsewd stsewd closed this Aug 31, 2022
@stsewd stsewd deleted the fix-subprojects-urlconf branch August 31, 2022 17:43
stsewd added a commit that referenced this pull request Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Accepted issue on our roadmap
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants