feat: default implementation for options that should be sufficient
This commit is contained in:
@@ -9,7 +9,7 @@ from pathlib import Path
|
||||
import inspect
|
||||
|
||||
from .metadata import Metadata
|
||||
from ..utils import get_unix_time, object_trace
|
||||
from ..utils import get_unix_time, object_trace, generate_id
|
||||
from ..utils.config import logging_settings, main_settings
|
||||
from ..utils.shared import HIGHEST_ID
|
||||
from ..utils.hacking import MetaClass
|
||||
@@ -29,6 +29,10 @@ class InnerData:
|
||||
"""
|
||||
|
||||
_refers_to_instances: set = None
|
||||
"""
|
||||
Attribute versions keep track, of if the attribute has been changed.
|
||||
"""
|
||||
_attribute_versions: Dict[str, int] = None
|
||||
|
||||
def __init__(self, object_type, **kwargs):
|
||||
self._refers_to_instances = set()
|
||||
@@ -84,8 +88,6 @@ class OuterProxy:
|
||||
DOWNWARDS_COLLECTION_STRING_ATTRIBUTES = tuple()
|
||||
UPWARDS_COLLECTION_STRING_ATTRIBUTES = tuple()
|
||||
|
||||
TITEL = "id"
|
||||
|
||||
def __init__(self, _id: int = None, dynamic: bool = False, **kwargs):
|
||||
_automatic_id: bool = False
|
||||
|
||||
@@ -94,7 +96,7 @@ class OuterProxy:
|
||||
generates a random integer id
|
||||
the range is defined in the config
|
||||
"""
|
||||
_id = random.randint(0, HIGHEST_ID)
|
||||
_id = generate_id()
|
||||
_automatic_id = True
|
||||
|
||||
kwargs["automatic_id"] = _automatic_id
|
||||
@@ -235,7 +237,17 @@ class OuterProxy:
|
||||
|
||||
@property
|
||||
def options(self) -> List[P]:
|
||||
return [self]
|
||||
r = []
|
||||
|
||||
for collection_string_attribute in self.UPWARDS_COLLECTION_STRING_ATTRIBUTES:
|
||||
r.extend(self.__getattribute__(collection_string_attribute))
|
||||
|
||||
r.append(self)
|
||||
|
||||
for collection_string_attribute in self.DOWNWARDS_COLLECTION_STRING_ATTRIBUTES:
|
||||
r.extend(self.__getattribute__(collection_string_attribute))
|
||||
|
||||
return r
|
||||
|
||||
@property
|
||||
def indexing_values(self) -> List[Tuple[str, object]]:
|
||||
@@ -267,6 +279,7 @@ class OuterProxy:
|
||||
|
||||
return r
|
||||
|
||||
TITEL = "id"
|
||||
@property
|
||||
def title_string(self) -> str:
|
||||
return str(self.__getattribute__(self.TITEL))
|
||||
|
@@ -117,7 +117,7 @@ class Song(Base):
|
||||
|
||||
Base.__init__(**locals())
|
||||
|
||||
UPWARDS_COLLECTION_STRING_ATTRIBUTES = ("album_collection", "main_artist_collection", "feature_artist_collection")
|
||||
UPWARDS_COLLECTION_STRING_ATTRIBUTES = ("main_artist_collection", "feature_artist_collection", "album_collection")
|
||||
TITEL = "title"
|
||||
|
||||
def __init_collections__(self) -> None:
|
||||
@@ -269,7 +269,7 @@ class Album(Base):
|
||||
**kwargs)
|
||||
|
||||
DOWNWARDS_COLLECTION_STRING_ATTRIBUTES = ("song_collection",)
|
||||
UPWARDS_COLLECTION_STRING_ATTRIBUTES = ("artist_collection", "label_collection")
|
||||
UPWARDS_COLLECTION_STRING_ATTRIBUTES = ("label_collection", "artist_collection")
|
||||
|
||||
def __init_collections__(self):
|
||||
self.song_collection.append_object_to_attribute = {
|
||||
|
Reference in New Issue
Block a user