dara-core 1.16.20a1__py3-none-any.whl → 1.16.21__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.
- dara/core/interactivity/loop_variable.py +1 -1
- dara/core/internal/routing.py +1 -1
- dara/core/persistence.py +20 -15
- dara/core/umd/dara.core.umd.js +3413 -8456
- dara/core/visual/components/for_cmp.py +2 -1
- {dara_core-1.16.20a1.dist-info → dara_core-1.16.21.dist-info}/METADATA +10 -10
- {dara_core-1.16.20a1.dist-info → dara_core-1.16.21.dist-info}/RECORD +10 -10
- {dara_core-1.16.20a1.dist-info → dara_core-1.16.21.dist-info}/LICENSE +0 -0
- {dara_core-1.16.20a1.dist-info → dara_core-1.16.21.dist-info}/WHEEL +0 -0
- {dara_core-1.16.20a1.dist-info → dara_core-1.16.21.dist-info}/entry_points.txt +0 -0
|
@@ -8,7 +8,7 @@ from .non_data_variable import NonDataVariable
|
|
|
8
8
|
class LoopVariable(NonDataVariable):
|
|
9
9
|
"""
|
|
10
10
|
A LoopVariable is a type of variable that represents an item in a list.
|
|
11
|
-
It should be constructed using a parent Variable's
|
|
11
|
+
It should be constructed using a parent Variable's `.list_item` property.
|
|
12
12
|
It should only be used in conjunction with the `For` component.
|
|
13
13
|
|
|
14
14
|
By default, the entire value is used as the item and the index in the list is used as the unique key.
|
dara/core/internal/routing.py
CHANGED
|
@@ -501,7 +501,7 @@ def create_router(config: Configuration):
|
|
|
501
501
|
async def _write(store_uid: str, value: Any):
|
|
502
502
|
WS_CHANNEL.set(ws_channel)
|
|
503
503
|
store_entry: BackendStoreEntry = await registry_mgr.get(backend_store_registry, store_uid)
|
|
504
|
-
result = store_entry.store.write(value)
|
|
504
|
+
result = store_entry.store.write(value, ignore_channel=ws_channel)
|
|
505
505
|
|
|
506
506
|
# Backend implementation could return a coroutine
|
|
507
507
|
if inspect.iscoroutine(result):
|
dara/core/persistence.py
CHANGED
|
@@ -29,7 +29,6 @@ from pydantic import (
|
|
|
29
29
|
|
|
30
30
|
from dara.core.auth.definitions import USER
|
|
31
31
|
from dara.core.internal.utils import run_user_handler
|
|
32
|
-
from dara.core.internal.websocket import WS_CHANNEL
|
|
33
32
|
from dara.core.logging import dev_logger
|
|
34
33
|
|
|
35
34
|
if TYPE_CHECKING:
|
|
@@ -318,7 +317,11 @@ class BackendStore(PersistenceStore):
|
|
|
318
317
|
if not payload or len(payload) != 1:
|
|
319
318
|
raise ValueError("Exactly one of 'value' or 'patches' must be provided")
|
|
320
319
|
|
|
321
|
-
return {
|
|
320
|
+
return {
|
|
321
|
+
'store_uid': self.uid,
|
|
322
|
+
'sequence_number': self.sequence_number.get(scope_key, 0),
|
|
323
|
+
**payload,
|
|
324
|
+
}
|
|
322
325
|
|
|
323
326
|
def _get_next_sequence_number(self, key: str) -> int:
|
|
324
327
|
"""
|
|
@@ -330,39 +333,40 @@ class BackendStore(PersistenceStore):
|
|
|
330
333
|
self.sequence_number[key] = current + 1
|
|
331
334
|
return self.sequence_number[key]
|
|
332
335
|
|
|
333
|
-
async def _notify_user(self, user_identifier: str,
|
|
336
|
+
async def _notify_user(self, user_identifier: str, ignore_channel: Optional[str] = None, **payload):
|
|
334
337
|
"""
|
|
335
338
|
Notify a given user about updates to this store.
|
|
336
339
|
:param user_identifier: user to notify
|
|
337
|
-
:param
|
|
340
|
+
:param ignore_channel: if specified, ignore the specified channel
|
|
338
341
|
:param payload: either value=... or patches=...
|
|
339
342
|
"""
|
|
340
343
|
return await self.ws_mgr.send_message_to_user(
|
|
341
344
|
user_identifier,
|
|
342
345
|
self._create_msg(user_identifier, **payload),
|
|
343
|
-
ignore_channel=
|
|
346
|
+
ignore_channel=ignore_channel,
|
|
344
347
|
)
|
|
345
348
|
|
|
346
|
-
async def _notify_global(self,
|
|
349
|
+
async def _notify_global(self, ignore_channel: Optional[str] = None, **payload):
|
|
347
350
|
"""
|
|
348
351
|
Notify all users about updates to this store.
|
|
349
|
-
:param
|
|
352
|
+
:param ignore_channel: if specified, ignore the specified channel
|
|
350
353
|
:param payload: either value=... or patches=...
|
|
351
354
|
"""
|
|
352
355
|
return await self.ws_mgr.broadcast(
|
|
353
356
|
self._create_msg('global', **payload),
|
|
354
|
-
ignore_channel=
|
|
357
|
+
ignore_channel=ignore_channel,
|
|
355
358
|
)
|
|
356
359
|
|
|
357
|
-
async def _notify_value(self, value: Any):
|
|
360
|
+
async def _notify_value(self, value: Any, ignore_channel: Optional[str] = None):
|
|
358
361
|
"""
|
|
359
362
|
Notify all clients about the new value for this store.
|
|
360
363
|
Broadcasts to all users if scope is global or sends to the current user if scope is user.
|
|
361
364
|
|
|
362
365
|
:param value: value to notify about
|
|
366
|
+
:param ignore_channel: if passed, ignore the specified channel when broadcasting
|
|
363
367
|
"""
|
|
364
368
|
if self.scope == 'global':
|
|
365
|
-
return await self._notify_global(value=value)
|
|
369
|
+
return await self._notify_global(value=value, ignore_channel=ignore_channel)
|
|
366
370
|
|
|
367
371
|
# For user scope, we need to find channels for the user and notify them
|
|
368
372
|
user = USER.get()
|
|
@@ -371,7 +375,7 @@ class BackendStore(PersistenceStore):
|
|
|
371
375
|
return
|
|
372
376
|
|
|
373
377
|
user_identifier = user.identity_id or user.identity_name
|
|
374
|
-
return await self._notify_user(user_identifier, value=value)
|
|
378
|
+
return await self._notify_user(user_identifier, value=value, ignore_channel=ignore_channel)
|
|
375
379
|
|
|
376
380
|
async def _notify_patches(self, patches: List[Dict[str, Any]]):
|
|
377
381
|
"""
|
|
@@ -406,8 +410,8 @@ class BackendStore(PersistenceStore):
|
|
|
406
410
|
async def _on_value(key: str, value: Any):
|
|
407
411
|
# here we explicitly DON'T ignore the current channel, in case we created this variable inside e.g. a py_component we want to notify its creator as well
|
|
408
412
|
if user := self._get_user(key):
|
|
409
|
-
return await self._notify_user(user,
|
|
410
|
-
return await self._notify_global(
|
|
413
|
+
return await self._notify_user(user, value=value)
|
|
414
|
+
return await self._notify_global(value=value)
|
|
411
415
|
|
|
412
416
|
await self.backend.subscribe(_on_value)
|
|
413
417
|
|
|
@@ -466,7 +470,7 @@ class BackendStore(PersistenceStore):
|
|
|
466
470
|
|
|
467
471
|
return updated_value
|
|
468
472
|
|
|
469
|
-
async def write(self, value: Any, notify=True):
|
|
473
|
+
async def write(self, value: Any, notify=True, ignore_channel: Optional[str] = None):
|
|
470
474
|
"""
|
|
471
475
|
Persist a value to the store.
|
|
472
476
|
|
|
@@ -475,6 +479,7 @@ class BackendStore(PersistenceStore):
|
|
|
475
479
|
|
|
476
480
|
:param value: value to write
|
|
477
481
|
:param notify: whether to broadcast the new value to clients
|
|
482
|
+
:param ignore_channel: if passed, ignore the specified websocket channel when broadcasting
|
|
478
483
|
"""
|
|
479
484
|
if self.readonly:
|
|
480
485
|
raise ValueError('Cannot write to a read-only store')
|
|
@@ -486,7 +491,7 @@ class BackendStore(PersistenceStore):
|
|
|
486
491
|
self._get_next_sequence_number(key)
|
|
487
492
|
|
|
488
493
|
if notify:
|
|
489
|
-
await self._notify_value(value)
|
|
494
|
+
await self._notify_value(value, ignore_channel=ignore_channel)
|
|
490
495
|
|
|
491
496
|
return res
|
|
492
497
|
|