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

Possible bug in routing.set_url_hash when load_from_cache=False #243

Closed
jshaffstall opened this issue Nov 28, 2021 · 2 comments · Fixed by #244
Closed

Possible bug in routing.set_url_hash when load_from_cache=False #243

jshaffstall opened this issue Nov 28, 2021 · 2 comments · Fixed by #244

Comments

@jshaffstall
Copy link
Contributor

I use code like this as part of my login sequence:

      anvil.users.login_with_form(allow_cancel=True)
      routing.set_url_hash(self.tag, load_from_cache=False, replace_current_url=True) 

The problem comes when the form the user is currently on is the same one referenced by self.tag. Given that I'm passing load_from_cache=False, I expected the form to be reloaded, with new calls to init and form_show.

Instead the form simply remained visible, with no calls to any function on the form.

The following code fixed the issue and caused the behavior I expected:

      anvil.users.login_with_form(allow_cancel=True)
      routing.remove_from_cache(self.tag)
      routing.set_url_hash(self.tag, load_from_cache=False, replace_current_url=True) 

Posting here in case this is a bug in the routing library that needs addressed.

@s-cork
Copy link
Collaborator

s-cork commented Nov 28, 2021

Did you want to make a pr for this? It's line 518 in _routing.py.

jshaffstall added a commit to jshaffstall/anvil-extras that referenced this issue Nov 28, 2021
remove the page from cache before checking to see if we can get by with doing nothing.   This addresses the issue described in anvilistas#243
@jshaffstall
Copy link
Contributor Author

I added a pull request for something I think will work. I do not have an app setup to test a custom version of Anvil Extras, though, so check over the logic to make sure I'm not missing something obvious.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants