spinetoolbox.fetch_parent
The FetchParent and FlexibleFetchParent classes.
Module Contents
Classes
|
|
|
|
|
|
dict() -> new empty dictionary |
|
- class spinetoolbox.fetch_parent.FetchParent(index=None, owner=None, chunk_size=1000)[source]
Bases:
PySide6.QtCore.QObject
- Parameters
index (FetchIndex, optional) – an index to speedup looking up fetched items
owner (object, optional) – somebody who owns this FetchParent. If it’s a QObject instance, then this FetchParent becomes obsolete whenever the owner is destroyed
chunk_size (int, optional) – the number of items this parent should be happy with fetching at a time. If None, then no limit is imposed and the parent should fetch the entire contents of the DB.
- abstract property fetch_item_type[source]
Returns the DB item type to fetch, e.g., “entity_class”.
- Returns
str
- key_for_index(db_map)[source]
Returns the key for this parent in the index.
- Parameters
db_map (DatabaseMapping) –
- Returns
Any
- accepts_item(item, db_map)[source]
Called by the associated SpineDBWorker whenever items are fetched and also added/updated/removed. Returns whether this parent accepts that item as a children.
In case of modifications, the SpineDBWorker will call one or more of
handle_items_added()
,handle_items_updated()
, orhandle_items_removed()
with all the items that pass this test.- Parameters
item (dict) – The item
db_map (DatabaseMapping) –
- Returns
bool
- shows_item(item, db_map)[source]
Called by the associated SpineDBWorker whenever items are fetched and accepted. Returns whether this parent will show this item to the user.
- Parameters
item (dict) – The item
db_map (DatabaseMapping) –
- Returns
bool
- set_obsolete(obsolete)[source]
Sets the obsolete status.
- Parameters
obsolete (bool) – whether parent has become obsolete
- set_fetched(fetched)[source]
Sets the fetched status.
- Parameters
fetched (bool) – whether parent has been fetched completely
- set_busy(busy)[source]
Sets the busy status.
- Parameters
busy (bool) – whether parent is busy fetching
- abstract handle_items_added(db_map_data)[source]
Called by SpineDBWorker when items are added to the DB.
- Parameters
db_map_data (dict) – Mapping DatabaseMapping instances to list of dict-items for which
accepts_item()
returns True.
- class spinetoolbox.fetch_parent.ItemTypeFetchParent(fetch_item_type, index=None, owner=None, chunk_size=1000)[source]
Bases:
FetchParent
- Parameters
index (FetchIndex, optional) – an index to speedup looking up fetched items
owner (object, optional) – somebody who owns this FetchParent. If it’s a QObject instance, then this FetchParent becomes obsolete whenever the owner is destroyed
chunk_size (int, optional) – the number of items this parent should be happy with fetching at a time. If None, then no limit is imposed and the parent should fetch the entire contents of the DB.
- property fetch_item_type[source]
Returns the DB item type to fetch, e.g., “entity_class”.
- Returns
str
- abstract handle_items_added(db_map_data)[source]
Called by SpineDBWorker when items are added to the DB.
- Parameters
db_map_data (dict) – Mapping DatabaseMapping instances to list of dict-items for which
accepts_item()
returns True.
- abstract handle_items_removed(db_map_data)[source]
Called by SpineDBWorker when items are removed from the DB.
- Parameters
db_map_data (dict) – Mapping DatabaseMapping instances to list of dict-items for which
accepts_item()
returns True.
- class spinetoolbox.fetch_parent.FlexibleFetchParent(fetch_item_type, handle_items_added=None, handle_items_removed=None, handle_items_updated=None, accepts_item=None, shows_item=None, key_for_index=None, index=None, owner=None, chunk_size=1000)[source]
Bases:
ItemTypeFetchParent
- Parameters
index (FetchIndex, optional) – an index to speedup looking up fetched items
owner (object, optional) – somebody who owns this FetchParent. If it’s a QObject instance, then this FetchParent becomes obsolete whenever the owner is destroyed
chunk_size (int, optional) – the number of items this parent should be happy with fetching at a time. If None, then no limit is imposed and the parent should fetch the entire contents of the DB.
- key_for_index(db_map)[source]
Returns the key for this parent in the index.
- Parameters
db_map (DatabaseMapping) –
- Returns
Any
- handle_items_added(db_map_data)[source]
Called by SpineDBWorker when items are added to the DB.
- Parameters
db_map_data (dict) – Mapping DatabaseMapping instances to list of dict-items for which
accepts_item()
returns True.
- handle_items_removed(db_map_data)[source]
Called by SpineDBWorker when items are removed from the DB.
- Parameters
db_map_data (dict) – Mapping DatabaseMapping instances to list of dict-items for which
accepts_item()
returns True.
- handle_items_updated(db_map_data)[source]
Called by SpineDBWorker when items are updated in the DB.
- Parameters
db_map_data (dict) – Mapping DatabaseMapping instances to list of dict-items for which
accepts_item()
returns True.
- accepts_item(item, db_map)[source]
Called by the associated SpineDBWorker whenever items are fetched and also added/updated/removed. Returns whether this parent accepts that item as a children.
In case of modifications, the SpineDBWorker will call one or more of
handle_items_added()
,handle_items_updated()
, orhandle_items_removed()
with all the items that pass this test.- Parameters
item (dict) – The item
db_map (DatabaseMapping) –
- Returns
bool
- class spinetoolbox.fetch_parent.FetchIndex[source]
Bases:
dict
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s
(key, value) pairs
- dict(iterable) -> new dictionary initialized as if via:
d = {} for k, v in iterable:
d[k] = v
- dict(**kwargs) -> new dictionary initialized with the name=value pairs
in the keyword argument list. For example: dict(one=1, two=2)
Initialize self. See help(type(self)) for accurate signature.