I’m running into some struggles with developing my energy system app.
I created classes that represent “energy assets”. So, in order to create and analyze an energy system, I create a class instance (asset) inside a view method. This works great for page 1 and allows me to visualize the energy asset.
But now when I reach page 2, I want to alter or add instance variables of the class instance (asset) and visualize this on the new page using a new view function. Is there a way to pass the class instance from the first view method to the second view method?
I tried a couple of things already:
- Created a function which creates the instance, this way I only have to call the function to get the instance. But this creates a new instance every time which is not preferred with future use of the app in mind.
- Defined an instance depository dict in the controller init, and tried to store my instances created in the view method in there. But this either gets cleared or not updated when reloading the second view.
- Created an InstanceDepository(dict) class to store the instances. But this way I need to pass the class as an argument in the view method call, which i cant find or is probably in the parametrization class Page(‘xxxx’, VIEWS=…), but I can’t pass any arguments here.
- The same problem (3.) occurs when using a depository dict as a Controller class “class-variable”.
Would you maybe have other suggestions?
Kind regards, Nino