Skip to content

Commit eb2d60d

Browse files
committed
refactors page handling
1 parent 7ff9263 commit eb2d60d

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

ngwidgets/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.22.0"
1+
__version__ = "0.22.1"

ngwidgets/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Version:
1717
name = "ngwidgets"
1818
version = ngwidgets.__version__
1919
date = "2023-09-10"
20-
updated = "2025-02-15"
20+
updated = "2025-02-19"
2121
description = "NiceGUI widgets"
2222

2323
authors = "Wolfgang Fahl"

ngwidgets/webserver.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,27 @@ async def page(self, client: Client, wanted_action: Callable, *args, **kwargs):
140140
solution_class = self.config.solution_class
141141
if not solution_class:
142142
raise TypeError("no solution_class configured")
143+
144+
action_result=await self.execute_action(client,
145+
solution_class,
146+
wanted_action,
147+
*args,
148+
**kwargs)
149+
return action_result
150+
151+
async def execute_action(self, client: Client, solution_class, wanted_action: Callable, *args, **kwargs):
152+
"""
153+
Execute the specified action on the solution instance.
154+
155+
Args:
156+
client (Client): The client making the request.
157+
solution_class: The solution class to create an instance for to execute the action on.
158+
wanted_action(Callable): The function to perform.
159+
args, *kwargs: Additional arguments to pass to the action.
160+
161+
Returns:
162+
The result of the action performed.
163+
"""
143164
solution_instance = solution_class(self, client)
144165

145166
# Check if the solution_instance is an instance of solution_class or its subclass
@@ -164,7 +185,8 @@ async def page(self, client: Client, wanted_action: Callable, *args, **kwargs):
164185
# are done
165186
solution_instance.prepare_ui()
166187

167-
return await action(*args, **kwargs)
188+
action_result= await action(*args, **kwargs)
189+
return action_result
168190

169191
@classmethod
170192
def optionalDebug(self, args):

0 commit comments

Comments
 (0)