reflex 0.7.4a3__py3-none-any.whl → 0.7.4.post1__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 reflex might be problematic. Click here for more details.

reflex/state.py CHANGED
@@ -1403,6 +1403,29 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
1403
1403
  for substate in self.substates.values():
1404
1404
  substate.reset()
1405
1405
 
1406
+ @classmethod
1407
+ @functools.lru_cache
1408
+ def _is_client_storage(cls, prop_name_or_field: str | ModelField) -> bool:
1409
+ """Check if the var is a client storage var.
1410
+
1411
+ Args:
1412
+ prop_name_or_field: The name of the var or the field itself.
1413
+
1414
+ Returns:
1415
+ Whether the var is a client storage var.
1416
+ """
1417
+ if isinstance(prop_name_or_field, str):
1418
+ field = cls.get_fields().get(prop_name_or_field)
1419
+ else:
1420
+ field = prop_name_or_field
1421
+ return field is not None and (
1422
+ isinstance(field.default, ClientStorageBase)
1423
+ or (
1424
+ isinstance(field.type_, type)
1425
+ and issubclass(field.type_, ClientStorageBase)
1426
+ )
1427
+ )
1428
+
1406
1429
  def _reset_client_storage(self):
1407
1430
  """Reset client storage base vars to their default values."""
1408
1431
  # Client-side storage is reset during hydrate so that clearing cookies
@@ -1410,10 +1433,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
1410
1433
  fields = self.get_fields()
1411
1434
  for prop_name in self.base_vars:
1412
1435
  field = fields[prop_name]
1413
- if isinstance(field.default, ClientStorageBase) or (
1414
- isinstance(field.type_, type)
1415
- and issubclass(field.type_, ClientStorageBase)
1416
- ):
1436
+ if self._is_client_storage(field):
1417
1437
  setattr(self, prop_name, copy.deepcopy(field.default))
1418
1438
 
1419
1439
  # Recursively reset the substate client storage.
@@ -2350,8 +2370,9 @@ class UpdateVarsInternalState(State):
2350
2370
  for var, value in vars.items():
2351
2371
  state_name, _, var_name = var.rpartition(".")
2352
2372
  var_state_cls = State.get_class_substate(state_name)
2353
- var_state = await self.get_state(var_state_cls)
2354
- setattr(var_state, var_name, value)
2373
+ if var_state_cls._is_client_storage(var_name):
2374
+ var_state = await self.get_state(var_state_cls)
2375
+ setattr(var_state, var_name, value)
2355
2376
 
2356
2377
 
2357
2378
  class OnLoadInternalState(State):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: reflex
3
- Version: 0.7.4a3
3
+ Version: 0.7.4.post1
4
4
  Summary: Web apps in pure Python.
5
5
  Project-URL: homepage, https://reflex.dev
6
6
  Project-URL: repository, https://github.com/reflex-dev/reflex
@@ -12,7 +12,7 @@ reflex/page.py,sha256=qEt8n5EtawSywCzdsiaNQJWhC8ie-vg8ig0JGuVavPI,2386
12
12
  reflex/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  reflex/reflex.py,sha256=ka_BOQTeC3jKwZflM3ka6aijvhFV0hNMzwUmBjH-iSU,21034
14
14
  reflex/route.py,sha256=nn_hJwtQdjiqH_dHXfqMGWKllnyPQZTSR-KWdHDhoOs,4210
15
- reflex/state.py,sha256=yWHL8V3j20thHrOa1_aT6gWTUFgTVnFPFIL5N922muo,141886
15
+ reflex/state.py,sha256=e2DgHlvSMnPD5QRXGdWhV6KAFBsvfq3yjHp7MnsBOtc,142565
16
16
  reflex/style.py,sha256=dilXPn8de80NzsXT53GPJrmjELC5nPYIlCgongyq1zM,13145
17
17
  reflex/testing.py,sha256=IpjUHBNOJDAQtu6HnazfWIacEO5cIJvyHlCr6dYpr38,35585
18
18
  reflex/.templates/apps/blank/assets/favicon.ico,sha256=baxxgDAQ2V4-G5Q4S2yK5uUJTUGkv-AOWBQ0xd6myUo,4286
@@ -397,8 +397,8 @@ reflex/vars/function.py,sha256=2sVnhgetPSwtor8VFtAiYJdzZ9IRNzAKdsUJG6dXQcE,14461
397
397
  reflex/vars/number.py,sha256=f0AeipAAbBJiHILym4bkJdOGqHnMpwNgQDeV6Lc_7ms,26781
398
398
  reflex/vars/object.py,sha256=-fGqHThozjxAAuQL-wTwEItPiFI-ps53P2bKoSlW_As,17081
399
399
  reflex/vars/sequence.py,sha256=S0WvU4gVP7_3WNLttEoaFgUqJRjCQhXT9Auzub04ZmM,55216
400
- reflex-0.7.4a3.dist-info/METADATA,sha256=whbzs3oRlZoZiXMfuWMiNKf-Hk1hq29rd4zHRVyQl5Y,12224
401
- reflex-0.7.4a3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
402
- reflex-0.7.4a3.dist-info/entry_points.txt,sha256=Rxt4dXc7MLBNt5CSHTehVPuSe9Xqow4HLX55nD9tQQ0,45
403
- reflex-0.7.4a3.dist-info/licenses/LICENSE,sha256=dw3zLrp9f5ObD7kqS32vWfhcImfO52PMmRqvtxq_YEE,11358
404
- reflex-0.7.4a3.dist-info/RECORD,,
400
+ reflex-0.7.4.post1.dist-info/METADATA,sha256=FVxj3Uf6jbc7x_RrSI5GOIw0dz7dU6OMQNvjmicgmTI,12228
401
+ reflex-0.7.4.post1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
402
+ reflex-0.7.4.post1.dist-info/entry_points.txt,sha256=Rxt4dXc7MLBNt5CSHTehVPuSe9Xqow4HLX55nD9tQQ0,45
403
+ reflex-0.7.4.post1.dist-info/licenses/LICENSE,sha256=dw3zLrp9f5ObD7kqS32vWfhcImfO52PMmRqvtxq_YEE,11358
404
+ reflex-0.7.4.post1.dist-info/RECORD,,