pyview-web 0.2.0__py3-none-any.whl → 0.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pyview-web might be problematic. Click here for more details.

@@ -0,0 +1,38 @@
1
+ from typing import Callable
2
+ import logging
3
+
4
+
5
+ def event(*event_names):
6
+ """Decorator that marks methods as event handlers."""
7
+
8
+ def decorator(func):
9
+ func._event_names = event_names
10
+ return func
11
+
12
+ return decorator
13
+
14
+
15
+ class BaseEventHandler:
16
+ """Base class for event handlers to handle dispatching events."""
17
+
18
+ _event_handlers: dict[str, Callable] = {}
19
+
20
+ def __init_subclass__(cls, **kwargs):
21
+ super().__init_subclass__(**kwargs)
22
+
23
+ # Find all decorated methods and register them
24
+ cls._event_handlers = {}
25
+ for attr_name in dir(cls):
26
+ if not attr_name.startswith("_"):
27
+ attr = getattr(cls, attr_name)
28
+ if hasattr(attr, "_event_names"):
29
+ for event_name in attr._event_names:
30
+ cls._event_handlers[event_name] = attr
31
+
32
+ async def handle_event(self, event: str, payload: dict, socket):
33
+ handler = self._event_handlers.get(event)
34
+
35
+ if handler:
36
+ return await handler(self, event, payload, socket)
37
+ else:
38
+ logging.warning(f"Unhandled event: {event} {payload}")
@@ -0,0 +1,4 @@
1
+ from .BaseEventHandler import BaseEventHandler, event
2
+ from .info_event import InfoEvent
3
+
4
+ __all__ = ["BaseEventHandler", "event", "InfoEvent"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pyview-web
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: LiveView in Python
5
5
  License: MIT
6
6
  Keywords: web,api,LiveView
@@ -8,7 +8,9 @@ pyview/auth/required.py,sha256=ZtNmLFth9nK39RxDiJkSzArXwS5Cvr55MUAzfJ1F2e0,1418
8
8
  pyview/changesets/__init__.py,sha256=55CLari2JHZtwy4hapHe7CqUyKjcP4dkM_t5d3CY2gU,46
9
9
  pyview/changesets/changesets.py,sha256=hImmvB_jS6RyLr5Mas5L7DO_0d805jR3c41LKJlnNL4,1720
10
10
  pyview/csrf.py,sha256=VIURva9EJqXXYGC7engweh3SwDQCnHlhV2zWdcdnFqc,789
11
- pyview/events.py,sha256=Zv8G2F1XeXUk1wrnfomeFfxB0OPYmHdjSvxRjQew3No,125
11
+ pyview/events/BaseEventHandler.py,sha256=RIv1vYn-sNIAfPNAaRg5iJvM--0ZlQHt3X7av_GR0sw,1138
12
+ pyview/events/__init__.py,sha256=5qQhZUjBwbnL9SrQ9FWHNgrEgDETCI3ysMREx7Tab4E,142
13
+ pyview/events/info_event.py,sha256=Zv8G2F1XeXUk1wrnfomeFfxB0OPYmHdjSvxRjQew3No,125
12
14
  pyview/js.py,sha256=E6HMsUfXQjrcLqYq26ieeYuzTjBeZqfJwwOm3uSR4ME,3498
13
15
  pyview/live_routes.py,sha256=IN2Jmy8b1umcfx1R7ZgFXHZNbYDJp_kLIbADtDJknPM,1749
14
16
  pyview/live_socket.py,sha256=D8fg7UQSPCVEboxohbDAZuK7J1xBEEoDycVFUuDfZxI,4767
@@ -42,7 +44,7 @@ pyview/vendor/ibis/template.py,sha256=6XJXnztw87CrOaKeW3e18LL0fNM8AI6AaK_QgMdb7e
42
44
  pyview/vendor/ibis/tree.py,sha256=hg8f-fKHeo6DE8R-QgAhdvEaZ8rKyz7p0nGwPy0CBTs,2509
43
45
  pyview/vendor/ibis/utils.py,sha256=nLSaxPR9vMphzV9qinlz_Iurv9c49Ps6Knv8vyNlewU,2768
44
46
  pyview/ws_handler.py,sha256=8iFKEse4TUaBzHF4xAcZiOqXaAgv4yB2CT0BKoW2Ny4,9319
45
- pyview_web-0.2.0.dist-info/LICENSE,sha256=M_bADaBm9_MV9llX3lCicksLhwk3eZUjA2srE0uUWr0,1071
46
- pyview_web-0.2.0.dist-info/METADATA,sha256=jWEXUjbxfTB87xaKUG2_NAnDB9Yz7BQ40Evr0bNGVK0,5256
47
- pyview_web-0.2.0.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
48
- pyview_web-0.2.0.dist-info/RECORD,,
47
+ pyview_web-0.2.1.dist-info/LICENSE,sha256=M_bADaBm9_MV9llX3lCicksLhwk3eZUjA2srE0uUWr0,1071
48
+ pyview_web-0.2.1.dist-info/METADATA,sha256=Od48u4VsUdsrfxHx0er1SGZNUgX4J5PBwI-9eIlQzm4,5256
49
+ pyview_web-0.2.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
50
+ pyview_web-0.2.1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.1.2
2
+ Generator: poetry-core 2.1.3
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
File without changes