Clean instance on logout + fixed InstancesDebugger.py
This commit is contained in:
@@ -86,6 +86,13 @@ class BaseInstance:
|
||||
def get_prefix(self) -> str:
|
||||
return self._prefix
|
||||
|
||||
def get_full_id(self) -> str:
|
||||
return f"{InstancesManager.get_session_id(self._session)}-{self._id}"
|
||||
|
||||
def get_full_parent_id(self) -> Optional[str]:
|
||||
parent = self.get_parent()
|
||||
return parent.get_full_id() if parent else None
|
||||
|
||||
@classmethod
|
||||
def compute_prefix(cls):
|
||||
return f"mf-{pascal_to_snake(cls.__name__)}"
|
||||
@@ -177,10 +184,33 @@ class InstancesManager:
|
||||
return "** UNKNOWN USER **"
|
||||
return session["user_info"].get("id", "** INVALID SESSION **")
|
||||
|
||||
@staticmethod
|
||||
def get_session_user_name(session):
|
||||
if session is None:
|
||||
return "** NOT LOGGED IN **"
|
||||
if "user_info" not in session:
|
||||
return "** UNKNOWN USER **"
|
||||
return session["user_info"].get("username", "** INVALID SESSION **")
|
||||
|
||||
@staticmethod
|
||||
def reset():
|
||||
InstancesManager.instances.clear()
|
||||
|
||||
@staticmethod
|
||||
def clear_session(session):
|
||||
"""
|
||||
Remove all instances belonging to the given session.
|
||||
:param session:
|
||||
:return:
|
||||
"""
|
||||
session_id = InstancesManager.get_session_id(session)
|
||||
|
||||
InstancesManager.instances = {
|
||||
key: instance
|
||||
for key, instance in InstancesManager.instances.items()
|
||||
if key[0] != session_id
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def dynamic_get(parent: BaseInstance, component_type: str, instance_id: str):
|
||||
logger.debug(f"Dynamic get: {component_type=} {instance_id=}")
|
||||
|
||||
Reference in New Issue
Block a user