Hi Everyone,
I have been trying to store two argument values inside a class argument. I used to get the data by pathname the assigned class attribute.
But, the issue is not updating on the page when the pathname is changing on the URL. I want the page to fully load every time the page URL pathname has been changed.
this is to get a pathname and assign it to the class object arguments.
cloud_obj = CloudFilter()
@callback(
Output("use_blank","children"),
Input("page_url", "pathname"),
#prevent_initial_call=True
)
def update_all_mode1(data_passing):
equipment_id = data_passing[1:11]
platform_id = data_passing[12:]
print(f"machine data: {equipment_id,platform_id}")
try:
cloud_obj = CloudFilter(platform_id, equipment_id)
time.sleep(2)
print(cloud_obj._platform_id)
except Exception as err:
print(f" select the machine: {err}")
return ''
This is the class argument assigning
class CloudFilter:
"""_Cloud all data filter to use on frontend_
"""
def __init__(self,platform_id="",equipment_id=""):
self._equipment_id = equipment_id
self._platform_id = platform_id
self.dflt_start_date = "2023-07-03"
self.dflt_end_date = "2023-07-10"
self.date_range_df = pd.to_datetime([self.dflt_start_date, self.dflt_end_date], format="%Y-%m-%d")
def get_platform_id(self):
return self._platform_id
def get_equipment_id(self):
return self._equipment_id
def set_platform_id(self,platform_id):
self._platform_id = platform_id
print(f"setter platform: {self._platform_id}")
def set_equipment_id(self,equipment_id):
self._equipment_id = equipment_id
print(f"setter equipment: {self._equipment_id}")
this is the page load code
cloud_obj = CloudFilter()
@callback(
Output('page_content', 'children'),
[Input('page_url', 'pathname')],
prevent_initial_call=True
)
def display_page(url_address):
if current_user.is_authenticated: # type: ignore
if url_address == '/url_path' or '/url_path_two':
# try:
# equipment_id = url_address[1:11]
# platform_id= url_address[12:]
# except Exception as err:
# print(f" url path is not getting a value: {err}")
# cloud_obj = CloudFilter(platform_id=platform_id,equipment_id=equipment_id)
# print(f"platform id: {cloud_obj._platform_id}")
# print(f"equipment_id: {cloud_obj._equipment_id}")
time.sleep(5)
return first_section,second_section,third_section,fourth_section
else:
return p404.p404_layout
I am just getting to know how could we load the page when the class is getting attribute value and then load the trending page.
Thanks in advance.