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

Set the default path_info to the root '/' #768

Closed
wants to merge 8 commits into from

Conversation

Projects
None yet
4 participants
@zhaoguixu
Copy link
Contributor

commented Sep 9, 2015

Set the default path_info to the root '/' when both the path_info passed to 'bind' and 'match' are None.
#740

@untitaker

This comment has been minimized.

Copy link
Member

commented Apr 10, 2016

@zhaoguixu Those tests fail for me. Could you take a look? Thanks!

@untitaker untitaker self-assigned this Apr 10, 2016

@untitaker untitaker added the waiting label Apr 10, 2016

Update test_routing.py
Fixed the new added test ``` test_both_bind_and_match_path_info_are_none``` to avoid failures

@zhaoguixu zhaoguixu referenced this pull request Apr 11, 2016

Merged

Update test_routing.py #3

Merge pull request #3 from zhaoguixu/zhaoguixu-patch-3
Update test_routing.py by fixing new added test  ```test_both_bind_and_match_path_info_are_none```
@zhaoguixu

This comment has been minimized.

Copy link
Contributor Author

commented Apr 11, 2016

This should be good. @untitaker

@untitaker

This comment has been minimized.

Copy link
Member

commented Apr 11, 2016

Please run make stylecheck on your code, some things are not conforming to the styleguide.

Will review content later.

@@ -1498,7 +1498,7 @@ def match(self, path_info=None, method=None, return_rule=False,
"""
self.map.update()
if path_info is None:
path_info = self.path_info
path_info = self.path_info or u'/'

This comment has been minimized.

Copy link
@untitaker

untitaker Apr 11, 2016

Member

Perhaps this logic would be better suited for bind, such that self.path_info is not None?

Something like:

diff --git a/werkzeug/routing.py b/werkzeug/routing.py
index 82cf793..888ac9b 100644
--- a/werkzeug/routing.py
+++ b/werkzeug/routing.py
@@ -1232,6 +1232,8 @@ class Map(object):
             subdomain = self.default_subdomain
         if script_name is None:
             script_name = '/'
+        if path_info is None:
+            path_info = '/'
         server_name = _encode_idna(server_name)
         return MapAdapter(self, server_name, script_name, subdomain,
                           url_scheme, path_info, default_method, query_args)
@@ -1498,7 +1500,7 @@ class MapAdapter(object):
         """
         self.map.update()
         if path_info is None:
-            path_info = self.path_info or u'/'
+            path_info = self.path_info
         else:
             path_info = to_unicode(path_info, self.map.charset)
         if query_args is None:
@untitaker

This comment has been minimized.

Copy link
Member

commented Apr 11, 2016

I don't really understand why you need this behavior in the first place. In which situation would you call match without arguments?

@zhaoguixu

This comment has been minimized.

Copy link
Contributor Author

commented Apr 11, 2016

Both the default value of path_info of method bind and match is None. This give us a sense None is acceptable. However, at most one of the two can accept None.

@untitaker

This comment has been minimized.

Copy link
Member

commented Apr 11, 2016

I think it was intended to just have no implicit default at all. That this is expressed with a 404 is unfortunate.

@zhaoguixu

This comment has been minimized.

Copy link
Contributor Author

commented Apr 11, 2016

I am not very familiar with the whole logic. I just test the two combined in one situation and it gives me a trackback. Feel free to decide whether this fix is necessary.

Update test_routing.py
Adjust styles.

@untitaker untitaker assigned mitsuhiko and unassigned untitaker Apr 13, 2016

@untitaker

This comment has been minimized.

Copy link
Member

commented Apr 13, 2016

Delegating to @mitsuhiko, because I don't really know.

@davidism davidism removed the waiting label May 23, 2018

@davidism davidism added this to the 0.15 milestone May 28, 2018

@davidism

This comment has been minimized.

Copy link
Member

commented May 28, 2018

continued in #1316

@davidism davidism closed this May 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.