Skip to content

Commit 953b896

Browse files
committed
Fix express module bookmarking
1 parent cbc303c commit 953b896

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

shiny/express/_stub_session.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,14 @@ def download(
149149

150150
class BookmarkExpressStub(Bookmark):
151151

152+
def __init__(self, root_session: ExpressStubSession) -> None:
153+
super().__init__(root_session)
154+
self._proxy_exclude_fns = []
155+
152156
def _get_bookmark_exclude(self) -> list[str]:
153-
raise NotImplementedError("Please call this only from a real session object")
157+
raise NotImplementedError(
158+
"Please call `._get_bookmark_exclude()` only from a real session object"
159+
)
154160

155161
def on_bookmark(
156162
self,
@@ -159,18 +165,26 @@ def on_bookmark(
159165
| Callable[[ShinySaveState], Awaitable[None]]
160166
),
161167
) -> None:
162-
raise NotImplementedError("Please call this only from a real session object")
168+
raise NotImplementedError(
169+
"Please call `.on_bookmark()` only from a real session object"
170+
)
163171

164172
def on_bookmarked(
165173
self,
166174
callback: Callable[[str], None] | Callable[[str], Awaitable[None]],
167175
) -> None:
168-
raise NotImplementedError("Please call this only from a real session object")
176+
raise NotImplementedError(
177+
"Please call `.on_bookmarked()` only from a real session object"
178+
)
169179

170180
async def update_query_string(
171181
self, query_string: str, mode: Literal["replace", "push"] = "replace"
172182
) -> None:
173-
raise NotImplementedError("Please call this only from a real session object")
183+
raise NotImplementedError(
184+
"Please call `.update_query_string()` only from a real session object"
185+
)
174186

175187
async def do_bookmark(self) -> None:
176-
raise NotImplementedError("Please call this only from a real session object")
188+
raise NotImplementedError(
189+
"Please call `.do_bookmark()` only from a real session object"
190+
)

shiny/session/_session.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,8 @@ def __init__(self, root_session: Session, ns: ResolvedId):
428428
async def scoped_on_bookmark(root_state: ShinySaveState) -> None:
429429
return await self._scoped_on_bookmark(root_state)
430430

431-
self._root_bookmark.on_bookmark(scoped_on_bookmark)
431+
if isinstance(self._root_session, BookmarkApp):
432+
self._root_bookmark.on_bookmark(scoped_on_bookmark)
432433

433434
# TODO: Barret - Implement restore scoped state!
434435

0 commit comments

Comments
 (0)