Skip to content

process events under authorization. #2540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 14, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 18 additions & 19 deletions taipy/gui_core/_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,16 @@ def __lazy_start(self):

def process_event(self, event: Event):
self.__lazy_start()
if event.entity_type is EventEntityType.SCENARIO:
with self.gui._get_authorization(system=True): # type: ignore
with self.gui._get_authorization(system=True): # type: ignore
if event.entity_type is EventEntityType.SCENARIO:
self.scenario_refresh(
event.entity_id
if event.operation is EventOperation.DELETION or is_readable(t.cast(ScenarioId, event.entity_id))
else None
)
elif event.entity_type is EventEntityType.SEQUENCE and event.entity_id:
sequence = None
try:
with self.gui._get_authorization(system=True): # type: ignore
elif event.entity_type is EventEntityType.SEQUENCE and event.entity_id:
sequence = None
try:
sequence = (
core_get(event.entity_id)
if event.operation is not EventOperation.DELETION
Expand All @@ -135,22 +134,22 @@ def process_event(self, event: Event):
)
if sequence and hasattr(sequence, "parent_ids") and sequence.parent_ids: # type: ignore
self.broadcast_core_changed({"scenario": list(sequence.parent_ids)}) # type: ignore
except Exception as e:
_warn(f"Access to sequence {event.entity_id} failed", e)
elif event.entity_type is EventEntityType.JOB:
with self.lock:
self.jobs_list = None
except Exception as e:
_warn(f"Access to sequence {event.entity_id} failed", e)
elif event.entity_type is EventEntityType.JOB:
with self.lock:
self.jobs_list = None
# no broadcast because the submission status will do the job
if event.operation is EventOperation.DELETION:
self.broadcast_core_changed({"jobs": True})
elif event.entity_type is EventEntityType.SUBMISSION:
self.submission_status_callback(event.entity_id, event)
elif event.entity_type is EventEntityType.DATA_NODE:
with self.lock:
self.data_nodes_by_owner = None
self.broadcast_core_changed(
{"datanode": event.entity_id if event.operation != EventOperation.DELETION else True}
)
elif event.entity_type is EventEntityType.SUBMISSION:
self.submission_status_callback(event.entity_id, event)
elif event.entity_type is EventEntityType.DATA_NODE:
with self.lock:
self.data_nodes_by_owner = None
self.broadcast_core_changed(
{"datanode": event.entity_id if event.operation != EventOperation.DELETION else True}
)

def broadcast_core_changed(self, payload: t.Dict[str, t.Any], client_id: t.Optional[str] = None):
self.gui._broadcast(_GuiCoreContext._CORE_CHANGED_NAME, payload, client_id) # type: ignore
Expand Down
Loading