Skip to content

Commit

Permalink
Merge pull request #532 from anvilistas/routing-redirect
Browse files Browse the repository at this point in the history
routing: fix redirect logic
  • Loading branch information
meatballs committed May 16, 2024
2 parents df2b4b1 + c7c4724 commit 6a8bb9c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
https://github.com/anvilistas/anvil-extras/issues/523
* MultiSelect - fix an issue with multiselect on the self hosted app server
https://github.com/anvilistas/anvil-extras/issues/525
* routing - fix redirect with None conditions
https://github.com/anvilistas/anvil-extras/pull/532


# v2.6.1 27-Mar-2024
Expand Down
10 changes: 8 additions & 2 deletions client_code/routing/_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,17 @@ def load_template_or_redirect(url_hash, url_pattern, url_dict, properties, nav_c
path = next(path for path in paths if url_hash.startswith(path))
except StopIteration:
continue

if condition is None:
break
pass
elif not condition():
continue
elif type(info) is TemplateInfo:

if type(info) is TemplateInfo:
break

redirect_hash = callable_()

if isinstance(redirect_hash, str):
if navigation_context.matches_current_context(redirect_hash):
# would cause an infinite loop
Expand All @@ -239,7 +243,9 @@ def load_template_or_redirect(url_hash, url_pattern, url_dict, properties, nav_c
nav_context.check_stale()

else:
# if no break
load_error_or_raise(f"no template for url_hash={url_hash!r}")

if current_template is callable_:
logger.debug(f"unchanged template: {callable_.__name__!r}")
return info, path
Expand Down
2 changes: 1 addition & 1 deletion client_code/zod/helpers/dict_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get(self, key, default=None):

def __repr__(self):
items = self.__dict__.items()
return f"{type(self).__name__}({', '.join(f'{k}={v!r}' for k,v in items)})"
return f"{type(self).__name__}({', '.join(f'{k}={v!r}' for k, v in items)})"

def __str__(self):
return str(self.__dict__)

0 comments on commit 6a8bb9c

Please sign in to comment.