Fixed tab recreation logic and improved error handling
This commit is contained in:
@@ -210,15 +210,24 @@ class InstancesManager:
|
||||
|
||||
@staticmethod
|
||||
def dynamic_get(session, component_parent: tuple, component: tuple):
|
||||
parent_type, parent_id = component_parent
|
||||
component_type, component_id = component
|
||||
|
||||
|
||||
# 1. Check if component already exists
|
||||
existing = InstancesManager.get(session, component_id, None)
|
||||
if existing is not None:
|
||||
logger.debug(f"Component {component_id} already exists, returning existing instance")
|
||||
return existing
|
||||
|
||||
# 2. Component doesn't exist, create it
|
||||
parent_type, parent_id = component_parent
|
||||
|
||||
# parent should always exist
|
||||
parent = InstancesManager.get(session, parent_id)
|
||||
|
||||
|
||||
real_component_type = snake_to_pascal(component_type.removeprefix("mf-"))
|
||||
component_full_type = f"myfasthtml.controls.{real_component_type}.{real_component_type}"
|
||||
cls = get_class(component_full_type)
|
||||
logger.debug(f"Creating new component {component_id} of type {real_component_type}")
|
||||
return cls(parent, _id=component_id)
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user