Continuing on a post yesterday, but still studying various options, I have a follow-up question.
After launching the below App, I click its Landing Page’s Login button which – via open_form() – takes me to the App Page and immediately issues a login form. When I submit a valid eMail address and click the received Magic Link, it takes me back the the Landing Page, and does not remain on the App Page (where the Magic Link was requested).
Simple Landing Page with Login Button:
# Set as the start Form.
class LandingForm(LandingFormTemplate):
def __init__(self, **properties):
self.init_components(**properties)
# Static page with a Login button.
def form_show(self, **properties):
pass
# Event handler for Login button click.
def btn_login_click(self, **event_args):
open_form('AppForm')
Simple App Page with Logout Button:
class AppForm(AppFormTemplate):
def __init__(self, **properties):
self.init_components(**properties)
def form_show(self, **properties):
if not anvil.users.get_user():
# <Code to hide unnecessary components>
anvil.users.login_with_form(allow_cancel=False, allow_remembered=False)
# <Code to reveal App components>
def btn_logout_click(self, **event_args):
anvil.users.logout()
open_form('LandingForm')
Does anyone know why it goes back to the Landing Page? By the way, this only happens with Magic Link, not with Google-based login.
The answer is the same as a previous post you made:
An entirely new application is opened. I assume you have the Landing Page set as the startup form, so it will always go there when a new application is made.
The confusion stemmed from this paragraph in the docs:
To display a new page, call open_form() (from the anvil module), and pass in the instance of the Form that you’d like to display as your new page. When you do this, the new Form takes over entirely and becomes the top-level Form. The old Form is no longer visible.
So I wasn’t expecting this, but…
correct.
Yes. Magic Link’s two-phases raise things (and understandings) you don’t encounter with until you use it. Back to the drawing board.
@anthonys I’ll just stay on the same App Form and turn off/on ColumnPanels as needed, like we discussed yesterday (and which I subtly hinted at in comments of form_show() above – you may have noticed). These explorations, while they feel like running in sand, do help. Thanks.
I know you’re in the “firehose” stage of consuming information, but i still think routing will save you some headaches later ( If you want to send links to specific pages among other things).
My first project did not use routing, but still used a central navigation module to control the flow of my application. Here is an example of that if it helps.
One good thing is that the application I’m working on has two parts. Part-A is for creation of content, which I’ve just about completed but for wrapping a landing and login workflow around it (ie, what I’ve been corresponding about with you and others the last few days). So I’m close there.
Here, we won’t talk about how the sausage was made LoL because I’ve probably made every mistake in the book (… well, I did revisit and fix a few along the way).
And then there’s Part-B. This is the consumption end (of content in Data Tables put in by creation). This is where I’ll be able to apply what the community has generously offered, and do things a little better. It’ll still be far from a work of art, but better thanks to the friendly community.