yes - it would be the equivalent of doing something natively in anvil a bit like
from .HomeForm import HomeForm
from .OtherForm import OtherForm
class MainForm(MainFormTemplate):
def __init__(self, **properties):
self._cache = {}
self._forms = {'home': HomeForm, 'other':OtherForm}
load_form('home')
def load_form(self, form_name):
form_to_load = self._cache.get(form_name)
if form_to_load is None:
# create an instance of the form_to_load and store in cache
form_to_load = self._forms[form_name]()
self._cache[form_name] = form_to_load
self.content_panel.clear()
# the current form_instance no longer has a parent so it is no longer visible
# but it still exists
# above we have stored the form_instance in self._cache to load whenever we need
self.content_panel.add_component(form_to_load)
In HashRouting
there are a couple of ways to interact with the _cache
routing._cache # private method to check the _cache - a dict of the form
# {url_hash: form_instance, ...}
routing.clear_cache()
routing.remove_from_cache(url_hash)