Fix user_id immutability issue
This commit is contained in:
parent
73e0cdba16
commit
e9871976ef
1 changed files with 3 additions and 3 deletions
|
|
@ -25,6 +25,7 @@ class Component:
|
||||||
code: Optional[str] = None
|
code: Optional[str] = None
|
||||||
_function_entrypoint_name: str = "build"
|
_function_entrypoint_name: str = "build"
|
||||||
field_config: dict = {}
|
field_config: dict = {}
|
||||||
|
_user_id: Optional[str]
|
||||||
|
|
||||||
def __init__(self, **data):
|
def __init__(self, **data):
|
||||||
self.cache = TTLCache(maxsize=1024, ttl=60)
|
self.cache = TTLCache(maxsize=1024, ttl=60)
|
||||||
|
|
@ -36,8 +37,7 @@ class Component:
|
||||||
|
|
||||||
def __setattr__(self, key, value):
|
def __setattr__(self, key, value):
|
||||||
if key == "_user_id" and hasattr(self, "_user_id"):
|
if key == "_user_id" and hasattr(self, "_user_id"):
|
||||||
warnings.warn("Modification of user_id is not allowed")
|
warnings.warn("user_id is immutable and cannot be changed.")
|
||||||
else:
|
|
||||||
super().__setattr__(key, value)
|
super().__setattr__(key, value)
|
||||||
|
|
||||||
@cachedmethod(cache=operator.attrgetter("cache"))
|
@cachedmethod(cache=operator.attrgetter("cache"))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue