X-Git-Url: https://plomlompom.com/repos/foo.html?a=blobdiff_plain;ds=inline;f=plomtask%2Fversioned_attributes.py;h=8861c9834ff3924d6459ced5cb9c69629424bb45;hb=0ccae4d00a38cc04c41cd0ee68e2aed896144fce;hp=b04c56465a74e1c7626736a0b7bb85f3ef5b8962;hpb=ae757881abfe760e8a942a4d2f0667dd7fa0ac4b;p=plomtask
diff --git a/plomtask/versioned_attributes.py b/plomtask/versioned_attributes.py
index b04c564..8861c98 100644
--- a/plomtask/versioned_attributes.py
+++ b/plomtask/versioned_attributes.py
@@ -4,7 +4,8 @@ from typing import Any
from sqlite3 import Row
from time import sleep
from plomtask.db import DatabaseConnection
-from plomtask.exceptions import HandledException, BadFormatException
+from plomtask.exceptions import (HandledException, BadFormatException,
+ NotFoundException)
TIMESTAMP_FMT = '%Y-%m-%d %H:%M:%S.%f'
@@ -25,14 +26,6 @@ class VersionedAttribute:
history_tuples)
return hash(hashable)
- @property
- def as_dict(self) -> dict[str, object]:
- """Return self as (json.dumps-coompatible) dict."""
- d = {'parent_id': self.parent.id_,
- 'table_name': self.table_name,
- 'history': self.history}
- return d
-
@property
def _newest_timestamp(self) -> str:
"""Return most recent timestamp."""
@@ -106,6 +99,8 @@ class VersionedAttribute:
def save(self, db_conn: DatabaseConnection) -> None:
"""Save as self.history entries, but first wipe old ones."""
+ if self.parent.id_ is None:
+ raise NotFoundException('cannot save attribute to parent if no ID')
db_conn.rewrite_relations(self.table_name, 'parent', self.parent.id_,
[[item[0], item[1]]
for item in self.history.items()])