Method: flask.app.Flask.create_url_adapter
Calls: 1043, Exceptions: 1, Paths: 4Back
Path 1: 517 calls (0.5)
None (517)
None (517)
1def create_url_adapter(self, request: Request | None) -> MapAdapter | None:
2 """Creates a URL adapter for the given request. The URL adapter
3 is created at a point where the request context is not yet set
4 up so the request is passed explicitly.
5
6 .. versionadded:: 0.6
7
8 .. versionchanged:: 0.9
9 This can now also be called without a request object when the
10 URL adapter is created for the application context.
11
12 .. versionchanged:: 1.0
13 :data:`SERVER_NAME` no longer implicitly enables subdomain
14 matching. Use :attr:`subdomain_matching` instead.
15 """
16 if request is not None:
17 # If subdomain matching is disabled (the default), use the
18 # default subdomain in all cases. This should be the default
19 # in Werkzeug but it currently does not have that feature.
20 if not self.subdomain_matching:
21 subdomain = self.url_map.default_subdomain or None
22 else:
23 subdomain = None
24
25 return self.url_map.bind_to_environ(
26 request.environ,
27 server_name=self.config["SERVER_NAME"],
28 subdomain=subdomain,
29 )
30 # We need at the very least the server name to be set for this
31 # to work.
32 if self.config["SERVER_NAME"] is not None:
33 return self.url_map.bind(
34 self.config["SERVER_NAME"],
35 script_name=self.config["APPLICATION_ROOT"],
36 url_scheme=self.config["PREFERRED_URL_SCHEME"],
37 )
38
39 return None
Path 2: 474 calls (0.45)
Request (474)
MapAdapter (473) None (1)
BadHost (1)
1def create_url_adapter(self, request: Request | None) -> MapAdapter | None:
2 """Creates a URL adapter for the given request. The URL adapter
3 is created at a point where the request context is not yet set
4 up so the request is passed explicitly.
5
6 .. versionadded:: 0.6
7
8 .. versionchanged:: 0.9
9 This can now also be called without a request object when the
10 URL adapter is created for the application context.
11
12 .. versionchanged:: 1.0
13 :data:`SERVER_NAME` no longer implicitly enables subdomain
14 matching. Use :attr:`subdomain_matching` instead.
15 """
16 if request is not None:
17 # If subdomain matching is disabled (the default), use the
18 # default subdomain in all cases. This should be the default
19 # in Werkzeug but it currently does not have that feature.
20 if not self.subdomain_matching:
21 subdomain = self.url_map.default_subdomain or None
22 else:
23 subdomain = None
24
25 return self.url_map.bind_to_environ(
26 request.environ,
27 server_name=self.config["SERVER_NAME"],
28 subdomain=subdomain,
29 )
30 # We need at the very least the server name to be set for this
31 # to work.
32 if self.config["SERVER_NAME"] is not None:
33 return self.url_map.bind(
34 self.config["SERVER_NAME"],
35 script_name=self.config["APPLICATION_ROOT"],
36 url_scheme=self.config["PREFERRED_URL_SCHEME"],
37 )
38
39 return None
Path 3: 35 calls (0.03)
None (35)
MapAdapter (35)
1def create_url_adapter(self, request: Request | None) -> MapAdapter | None:
2 """Creates a URL adapter for the given request. The URL adapter
3 is created at a point where the request context is not yet set
4 up so the request is passed explicitly.
5
6 .. versionadded:: 0.6
7
8 .. versionchanged:: 0.9
9 This can now also be called without a request object when the
10 URL adapter is created for the application context.
11
12 .. versionchanged:: 1.0
13 :data:`SERVER_NAME` no longer implicitly enables subdomain
14 matching. Use :attr:`subdomain_matching` instead.
15 """
16 if request is not None:
17 # If subdomain matching is disabled (the default), use the
18 # default subdomain in all cases. This should be the default
19 # in Werkzeug but it currently does not have that feature.
20 if not self.subdomain_matching:
21 subdomain = self.url_map.default_subdomain or None
22 else:
23 subdomain = None
24
25 return self.url_map.bind_to_environ(
26 request.environ,
27 server_name=self.config["SERVER_NAME"],
28 subdomain=subdomain,
29 )
30 # We need at the very least the server name to be set for this
31 # to work.
32 if self.config["SERVER_NAME"] is not None:
33 return self.url_map.bind(
34 self.config["SERVER_NAME"],
35 script_name=self.config["APPLICATION_ROOT"],
36 url_scheme=self.config["PREFERRED_URL_SCHEME"],
37 )
38
39 return None
Path 4: 17 calls (0.02)
Request (17)
MapAdapter (17)
1def create_url_adapter(self, request: Request | None) -> MapAdapter | None:
2 """Creates a URL adapter for the given request. The URL adapter
3 is created at a point where the request context is not yet set
4 up so the request is passed explicitly.
5
6 .. versionadded:: 0.6
7
8 .. versionchanged:: 0.9
9 This can now also be called without a request object when the
10 URL adapter is created for the application context.
11
12 .. versionchanged:: 1.0
13 :data:`SERVER_NAME` no longer implicitly enables subdomain
14 matching. Use :attr:`subdomain_matching` instead.
15 """
16 if request is not None:
17 # If subdomain matching is disabled (the default), use the
18 # default subdomain in all cases. This should be the default
19 # in Werkzeug but it currently does not have that feature.
20 if not self.subdomain_matching:
21 subdomain = self.url_map.default_subdomain or None
22 else:
23 subdomain = None
24
25 return self.url_map.bind_to_environ(
26 request.environ,
27 server_name=self.config["SERVER_NAME"],
28 subdomain=subdomain,
29 )
30 # We need at the very least the server name to be set for this
31 # to work.
32 if self.config["SERVER_NAME"] is not None:
33 return self.url_map.bind(
34 self.config["SERVER_NAME"],
35 script_name=self.config["APPLICATION_ROOT"],
36 url_scheme=self.config["PREFERRED_URL_SCHEME"],
37 )
38
39 return None