Skip to content

Commit 46628e7

Browse files
committed
entity: added __getattr__ overload to access property #29
1 parent f94d1e4 commit 46628e7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

objectbox/model/entity.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ def __call__(self, **properties):
6868
setattr(object_, prop_name, prop_val)
6969
return object_
7070

71+
def __getattr__(self, name):
72+
""" Overload to get properties via "<Entity>.<Prop>" notation. """
73+
for prop in self.properties:
74+
if prop._name == name:
75+
return prop
76+
return self.__getattribute__(name)
77+
7178
def fill_properties(self):
7279
# TODO allow subclassing and support entities with __slots__ defined
7380
variables = dict(vars(self.user_type))

0 commit comments

Comments
 (0)