Add attribute deleted to all objects, for held instances.
If an instance is being held in two places, and then one of them calls delete(), the other can check deleted before doing anything with the object.
This commit is contained in:
parent
f70349470f
commit
85260144ef
1 changed files with 6 additions and 0 deletions
|
@ -33,6 +33,7 @@ class ObjectBase:
|
||||||
def __init__(self, photodb):
|
def __init__(self, photodb):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.photodb = photodb
|
self.photodb = photodb
|
||||||
|
self.deleted = False
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
return (
|
return (
|
||||||
|
@ -157,6 +158,7 @@ class GroupableMixin:
|
||||||
# issues of recursion.
|
# issues of recursion.
|
||||||
self.photodb.sql_delete(table=self.group_table, pairs={'memberid': self.id})
|
self.photodb.sql_delete(table=self.group_table, pairs={'memberid': self.id})
|
||||||
self._uncache()
|
self._uncache()
|
||||||
|
self.deleted = True
|
||||||
|
|
||||||
def get_children(self):
|
def get_children(self):
|
||||||
child_rows = self.photodb.sql_select(
|
child_rows = self.photodb.sql_select(
|
||||||
|
@ -372,6 +374,7 @@ class Album(ObjectBase, GroupableMixin):
|
||||||
self.photodb.sql_delete(table='album_photo_rel', pairs={'albumid': self.id})
|
self.photodb.sql_delete(table='album_photo_rel', pairs={'albumid': self.id})
|
||||||
self.photodb.sql_delete(table='albums', pairs={'id': self.id})
|
self.photodb.sql_delete(table='albums', pairs={'id': self.id})
|
||||||
self._uncache()
|
self._uncache()
|
||||||
|
self.deleted = True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def display_name(self):
|
def display_name(self):
|
||||||
|
@ -596,6 +599,7 @@ class Bookmark(ObjectBase):
|
||||||
def delete(self):
|
def delete(self):
|
||||||
self.photodb.sql_delete(table='bookmarks', pairs={'id': self.id})
|
self.photodb.sql_delete(table='bookmarks', pairs={'id': self.id})
|
||||||
self._uncache()
|
self._uncache()
|
||||||
|
self.deleted = True
|
||||||
|
|
||||||
@decorators.required_feature('bookmark.edit')
|
@decorators.required_feature('bookmark.edit')
|
||||||
@decorators.transaction
|
@decorators.transaction
|
||||||
|
@ -775,6 +779,7 @@ class Photo(ObjectBase):
|
||||||
queue_action = {'action': action, 'args': [path]}
|
queue_action = {'action': action, 'args': [path]}
|
||||||
self.photodb.on_commit_queue.append(queue_action)
|
self.photodb.on_commit_queue.append(queue_action)
|
||||||
self._uncache()
|
self._uncache()
|
||||||
|
self.deleted = True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def duration_string(self):
|
def duration_string(self):
|
||||||
|
@ -1365,6 +1370,7 @@ class Tag(ObjectBase, GroupableMixin):
|
||||||
self.photodb.sql_delete(table='tags', pairs={'id': self.id})
|
self.photodb.sql_delete(table='tags', pairs={'id': self.id})
|
||||||
self.photodb.caches['tag_exports'].clear()
|
self.photodb.caches['tag_exports'].clear()
|
||||||
self._uncache()
|
self._uncache()
|
||||||
|
self.deleted = True
|
||||||
|
|
||||||
@decorators.required_feature('tag.edit')
|
@decorators.required_feature('tag.edit')
|
||||||
@decorators.transaction
|
@decorators.transaction
|
||||||
|
|
Loading…
Reference in a new issue