refactor to rx.Config
This commit is contained in:
parent
2146632e79
commit
a5ed8d9da9
@ -564,9 +564,6 @@ class EnvironmentVariables:
|
||||
# The maximum size of the reflex state in kilobytes.
|
||||
REFLEX_STATE_SIZE_LIMIT: EnvVar[int] = env_var(1000)
|
||||
|
||||
# Whether to automatically create setters for state base vars
|
||||
REFLEX_AUTO_CREATE_SETTERS: EnvVar[bool] = env_var(True)
|
||||
|
||||
|
||||
environment = EnvironmentVariables()
|
||||
|
||||
@ -686,6 +683,9 @@ class Config(Base):
|
||||
# Path to file containing key-values pairs to override in the environment; Dotenv format.
|
||||
env_file: Optional[str] = None
|
||||
|
||||
# Whether to automatically create setters for state base vars
|
||||
state_auto_setters: bool = True
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""Initialize the config values.
|
||||
|
||||
|
@ -43,7 +43,7 @@ from sqlalchemy.orm import DeclarativeBase
|
||||
from typing_extensions import Self
|
||||
|
||||
from reflex import event
|
||||
from reflex.config import EnvironmentVariables, PerformanceMode, get_config
|
||||
from reflex.config import PerformanceMode, get_config
|
||||
from reflex.istate.data import RouterData
|
||||
from reflex.istate.storage import ClientStorageBase
|
||||
from reflex.model import Model
|
||||
@ -979,7 +979,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
|
||||
f'Found var "{prop._js_expr}" with type {prop._var_type}.'
|
||||
)
|
||||
cls._set_var(prop)
|
||||
if EnvironmentVariables.REFLEX_AUTO_CREATE_SETTERS.get():
|
||||
if get_config().state_auto_setters:
|
||||
cls._create_setter(prop)
|
||||
cls._set_default_value(prop)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user