Skip to content

Conversation

dimrozakis
Copy link
Contributor

To make it easier for subclasses to modify behavior.

@coveralls
Copy link

coveralls commented Feb 22, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 0431226 on dimrozakis:get_path into bafc394 on TracyWebTech:master.

@seocam
Copy link
Contributor

seocam commented Feb 24, 2017

That method isn't actually getting the path it's only pre-processing the path before returning. Can you give me some cases where having this method would be relevant?

Thanks!

@dimrozakis
Copy link
Contributor Author

dimrozakis commented Feb 24, 2017

Hey @seocam

So, what I was trying to do was to proxy rabbitmq's management web UI/API. Rabbitmq has a concept of vhosts, which are present in the API paths. The default rabbitmq vhost is /. When any query is performed concerning the / vhost, this is encoded in the path like this api/queues/%2F/some-queue.

However, what ended up being proxied was api/queues///some-queue which would fail.

Unfortunately, as far as I can tell, django's uri parsing happens on the unescaped data, so the path matched by the regex in the url conf would always contain ///. In order to work around this, I defined my own subclass of ProxyView, and had the dispatch method replace /// with /%2f/ before calling ProxyView's dispatch method. However, this wouldn't work, as quote_plus would turn it to /%252f/.

By moving the preprocessing of path to a different method, I was able to define my own subclass of ProxyView which only extends get_path, replacing /// with /%2f/ after it has been quoted.

I know it isn't the cleaner solution, do you have any suggestions as to how else I could have achieved my goal of properly proxying /%2f/?

@dimrozakis
Copy link
Contributor Author

Unfortunately, as far as I can tell, django's uri parsing happens on the unescaped data, so the path matched by the regex in the url conf would always contain ///.

https://code.djangoproject.com/ticket/15718

@seocam
Copy link
Contributor

seocam commented Feb 24, 2017

Thanks for the clarification @dimrozakis! What about calling this method get_quoted_path?

To make it easier for subclasses to modify behavior.
@dimrozakis
Copy link
Contributor Author

dimrozakis commented Feb 24, 2017

@seocam sure thing. I renamed the function as suggested, squashed and pushed.

@coveralls
Copy link

coveralls commented Feb 24, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 14efb4f on dimrozakis:get_path into bafc394 on TracyWebTech:master.

@seocam seocam merged commit 37db80f into jazzband:master Feb 24, 2017
@dimrozakis dimrozakis deleted the get_path branch February 25, 2017 15:42
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.

3 participants