You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from .._utilsimportAsyncCallbacks, CancelCallback, wrap_async
9
-
from ..typesimportMISSING, MISSING_TYPE
10
9
from ._buttonimportBOOKMARK_ID
11
10
from ._restore_stateimportRestoreState
12
11
from ._save_stateimportBookmarkState
@@ -62,41 +61,33 @@
62
61
ifTYPE_CHECKING:
63
62
from ..express._stub_sessionimportExpressStubSession
64
63
from ..moduleimportResolvedId
65
-
from ..sessionimportSession
66
-
from ..session._sessionimportSessionProxy
64
+
from ..session._sessionimportAppSession, SessionProxy
67
65
from . importRestoreContext
68
66
else:
69
67
fromtypingimportAny
70
68
71
69
RestoreContext=Any
72
-
Session=Any
73
70
SessionProxy=Any
71
+
AppSession=Any
74
72
ResolvedId=Any
75
73
ExpressStubSession=Any
76
74
77
75
78
-
# TODO: future - Local storage Bookmark class!
79
-
# * Needs a consistent id for storage.
80
-
# * Needs ways to clean up other storage
81
-
# * Needs ways to see available IDs
82
-
83
-
84
76
classBookmark(ABC):
85
77
86
-
_session_root: Session
87
-
"""
88
-
The root session object (most likely a `AppSession` object).
89
-
"""
90
-
91
-
_store: BookmarkStore|MISSING_TYPE
92
-
"""
93
-
Session specific bookmark store value.
78
+
_proxy_exclude_fns: list[Callable[[], list[str]]]
79
+
"""Callbacks that BookmarkProxy classes utilize to help determine the list of inputs to exclude from bookmarking."""
80
+
exclude: list[str]
81
+
"""A list of scoped Input names to exclude from bookmarking."""
94
82
95
-
This value could help determine how session state is saved. However, app authors will not be able to change how the session is restored as the server function will run after the session has been restored.
96
-
"""
83
+
_on_bookmark_callbacks: AsyncCallbacks
84
+
_on_bookmarked_callbacks: AsyncCallbacks
85
+
_on_restore_callbacks: AsyncCallbacks
86
+
_on_restored_callbacks: AsyncCallbacks
97
87
98
88
# Making this a read only property as app authors will not be able to change how the session is restored as the server function will run after the session has been restored.
This should only be done within the `init` websocket message.
116
+
"""
117
+
...
142
118
143
-
def__init__(self, session_root: Session):
144
-
# from ._restore_state import RestoreContext
119
+
asyncdef__call__(self) ->None:
120
+
awaitself.do_bookmark()
121
+
122
+
def__init__(self):
145
123
146
124
super().__init__()
147
-
self._session_root=session_root
148
-
self._restore_context_value=None
149
-
self._store=MISSING
150
125
151
126
self._proxy_exclude_fns= []
152
127
self.exclude= []
@@ -288,8 +263,47 @@ def on_restored(
288
263
289
264
290
265
classBookmarkApp(Bookmark):
291
-
def__init__(self, session_root: Session):
292
-
super().__init__(session_root)
266
+
_session: AppSession
267
+
"""
268
+
The root session object (most likely a `AppSession` object).
269
+
"""
270
+
_restore_context_value: RestoreContext
271
+
"""
272
+
Placeholder value that should only be manually set within the session's `init` websocket message.
273
+
"""
274
+
275
+
def__init__(self, session: AppSession):
276
+
from ..session._sessionimportAppSession
277
+
278
+
assertisinstance(session, AppSession)
279
+
super().__init__()
280
+
281
+
self._session=session
282
+
# self._restore_context_value = None
283
+
284
+
# Making this a read only property as app authors will not be able to change how the session is restored as the server function will run after the session has been restored.
285
+
@property
286
+
defstore(self) ->BookmarkStore:
287
+
"""
288
+
App's bookmark store value
289
+
290
+
Possible values:
291
+
* `"url"`: Save / reload the bookmark state in the URL.
292
+
* `"server"`: Save / reload the bookmark state on the server.
293
+
* `"disable"` (default): Bookmarking is diabled.
294
+
"""
295
+
296
+
returnself._session.app.bookmark_store
297
+
298
+
@property
299
+
def_restore_context(self) ->RestoreContext|None:
300
+
"""
301
+
A read-only value of the session's RestoreContext object.
0 commit comments