Skip to content
This repository was archived by the owner on Jun 11, 2024. It is now read-only.

Commit 42eddfd

Browse files
committed
Don't require id if attribute already exists
1 parent 0172c10 commit 42eddfd

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

atomx/models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ def __getattr__(self, item):
5656
model_name = get_attribute_model_name(item)
5757
attr = self._attributes.get(item)
5858

59-
# loading of extra data is only possible if model ID is known
60-
if 'id' not in self._attributes:
61-
raise AttributeError('Model needs at least an `id` value to load more attributes.')
6259
# if requested attribute item is a valid model name and and int or
6360
# a list of integers, just delete the attribute so it gets
6461
# fetched from the api
@@ -70,6 +67,9 @@ def __getattr__(self, item):
7067
# if item not in model and session exists,
7168
# try to load model attribute from server if possible
7269
if not item.startswith('_') and item not in self._attributes and self.session:
70+
# loading of extra data is only possible if model ID is known
71+
if 'id' not in self._attributes:
72+
raise AttributeError('Model needs at least an `id` value to load more attributes.')
7373
try:
7474
v = self.session.get(self.__class__._resource_name, self.id, item)
7575
self._attributes[item] = v

0 commit comments

Comments
 (0)