Hello Friends:
Following on the heels of this post, I have variation of that question.
I have a Landing Page Form and an App Page Form that I want to sequence logins / logouts between. They share no components. I have a prototype solution which I don’t like, and am posting it here hoping for assistance on improving it.
Here it is.
Here’s the trivial App Page (with a Logout button) and its Form code:
class AppForm(AppFormTemplate):
def __init__(self, **properties):
open_form('LandingForm')
self.init_components(**properties)
validate_login() # Post login_with_form() validations performed here.
# Event handler for Logout button click.
def btn_logout_click(self, **event_args):
anvil.users.logout()
open_form('LandingForm')
Here’s the trivial Landing Page (with a Login button) and its Form code:
class LandingForm(LandingFormTemplate):
def __init__(self, **properties):
self.init_components(**properties)
def form_show(self, **properties):
while not anvil.users.get_user():
time.sleep(20) # Try not to laugh. LoL
# Event handler for Login button click.
def btn_login_click(self, **event_args):
anvil.users.login_with_form(allow_cancel=True, allow_remembered=False)
Of course, I don’t like the time.sleep(…). SideNote: Because I’m using Magic Link logins, the number of delay-seconds (whether 20 or 200,000) doesn’t actually matter because, when the user clicks the Magic Link, form_show() runs a second time where the while / loop condition is immediately breached and never entered. This would fail with, say, Google based logins.
Any suggestions on rearranging this code to eliminate time.sleep(…) and generally improve things?
Thank you!