Problem loading route when another form was during the call

What I’m trying to do:
Redirect between multi pages using routing.set_url_hash()
What I’ve tried and what’s not working:
Get a form empty and catch log error like

 #routing: problem loading route: 'Preview'. Another form was during the call to __init__. exiting this navigation
    #routing: exiting navigation level: 2

Code Sample:

before:
  def __init__(self, **properties):
    self.init_components(**properties)
    anvil.server.call("functionA")
    anvil.server.call("functionB")
    anvil.server.call("functionC")

-----//----
after:
  def __init__(self, **properties):
    self.init_components(**properties)
    self.add_event_handler('show', self.form_show)
  
  def form_show(self, **event_args):
    anvil.server.call("functionA")
    anvil.server.call("functionB")
    anvil.server.call("functionC")

I have moved the call to server code, which might be better. Is there any other way that is even more optimal?
Clone link:
share a copy of your app

I’m honestly not sure exactly what you’re asking.

It sounds like you’re asking why routing.set_url_hash in __init__ didn’t work. You’re right, it doesn’t work there because the form that’s being constructed isn’t actually open at that point. If you want an immediate redirect to another form, it needs to be in the form show event. (edit: I think I remember Stu fixing this at some point, so it may work in __init__ now).

But, your sample code doesn’t use routing.set_url_hash, so maybe that’s not what you’re asking? You also shouldn’t be able to set the url hash from server code since that code isn’t running in the browser.

As a side note, making several server calls in succession like you’re showing is going to be slow since each server call has the network communication overhead of around 3 seconds. Instead, make a single server call that does the work that the three would have done.

If you include more details on what you’re asking, and sample code that shows the issue, we’ll have a better chance of helping.