瀏覽代碼

nullcontext is not always good :-) (#1972)

* nullcontext is not always good :-)

* always allow scenario creation
(will make it dynamic later)

* remove unused import

* message

---------

Co-authored-by: Fred Lefévère-Laoide <Fred.Lefevere-Laoide@Taipy.io>
Co-authored-by: jrobinAV <jeanrobin.medori@avaiga.com>
Fred Lefévère-Laoide 7 月之前
父節點
當前提交
a085ba7265
共有 2 個文件被更改,包括 8 次插入3 次删除
  1. 5 1
      taipy/gui/gui.py
  2. 3 2
      taipy/gui_core/_context.py

+ 5 - 1
taipy/gui/gui.py

@@ -2880,7 +2880,11 @@ class Gui:
             _TaipyLogger._get_logger().info("Gui server has been stopped.")
 
     def _get_authorization(self, client_id: t.Optional[str] = None, system: t.Optional[bool] = False):
-        return contextlib.nullcontext()
+        try:
+            return _Hooks()._get_authorization(self, client_id, system) or contextlib.nullcontext()
+        except Exception as e:
+            _warn("Hooks:", e)
+            return contextlib.nullcontext()
 
     def set_favicon(self, favicon_path: t.Union[str, Path], state: t.Optional[State] = None):
         """Change the favicon for all clients.

+ 3 - 2
taipy/gui_core/_context.py

@@ -56,7 +56,6 @@ from taipy.core.notification.event import Event, EventOperation
 from taipy.core.notification.notifier import Notifier
 from taipy.core.reason import ReasonCollection
 from taipy.core.submission.submission_status import SubmissionStatus
-from taipy.core.taipy import can_create
 from taipy.gui import Gui, State
 from taipy.gui._warnings import _warn
 from taipy.gui.gui import _DoNotUpdate
@@ -1202,7 +1201,9 @@ class _GuiCoreContext(CoreEventConsumerBase):
 
     def get_creation_reason(self):
         self.__lazy_start()
-        return "" if (reason := can_create()) else f"Cannot create scenario: {_get_reason(reason)}"
+        # make this dynamic
+        # return "" if (reason := can_create()) else f"Cannot create scenario: {_get_reason(reason)}"
+        return ""
 
     def on_file_action(self, state: State, id: str, payload: t.Dict[str, t.Any]):
         args = t.cast(list, payload.get("args"))