fix: syncronization of data objects in more complex constelations
This commit is contained in:
parent
70b86b5c47
commit
60dc5b2558
@ -26,7 +26,12 @@ if __name__ == "__main__":
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
print(artist.main_album_collection[0].barcode)
|
a = artist.main_album_collection[0]
|
||||||
print(artist.main_album_collection[0].albumsort)
|
b = a.song_collection[0].album_collection[0]
|
||||||
|
c = a.song_collection[1].album_collection[0]
|
||||||
|
|
||||||
|
print(a.id, a.barcode, a.albumsort)
|
||||||
|
print(b.id, b.barcode, b.albumsort)
|
||||||
|
print(c.id, c.barcode, c.albumsort)
|
||||||
|
print()
|
||||||
print(artist.main_album_collection._indexed_values)
|
print(artist.main_album_collection._indexed_values)
|
@ -26,6 +26,8 @@ class InnerData:
|
|||||||
If the data in the wrapper class has to be merged, then this class is just replaced and garbage collected.
|
If the data in the wrapper class has to be merged, then this class is just replaced and garbage collected.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
_multiple_instances = False
|
||||||
|
|
||||||
def __init__(self, object_type, **kwargs):
|
def __init__(self, object_type, **kwargs):
|
||||||
# initialize the default values
|
# initialize the default values
|
||||||
self.__default_values = {}
|
self.__default_values = {}
|
||||||
@ -177,10 +179,20 @@ class OuterProxy:
|
|||||||
_ = "debug"
|
_ = "debug"
|
||||||
return
|
return
|
||||||
|
|
||||||
print(__other)
|
a = self
|
||||||
|
b = __other
|
||||||
|
|
||||||
self._inner.__merge__(__other._inner, override=override)
|
if a._inner._multiple_instances and b._inner._multiple_instances:
|
||||||
__other._inner = self._inner
|
LOGGER.warning(f"Both instances data obj are shared over multiple objects. This will lead so them being unsynchronized at some point. {a} {b}")
|
||||||
|
|
||||||
|
if b._inner._multiple_instances:
|
||||||
|
a, b = b, a
|
||||||
|
|
||||||
|
a._inner.__merge__(b._inner, override=override)
|
||||||
|
b._inner = a._inner
|
||||||
|
|
||||||
|
|
||||||
|
b._inner._multiple_instances = True
|
||||||
|
|
||||||
def mark_as_fetched(self, *url_hash_list: List[str]):
|
def mark_as_fetched(self, *url_hash_list: List[str]):
|
||||||
for url_hash in url_hash_list:
|
for url_hash in url_hash_list:
|
||||||
|
Loading…
Reference in New Issue
Block a user