Added __delitem__ support to PackedDict/List, allowing for things like in-place "del obj.db.dict[key]".
This commit is contained in:
parent
e4382e3e8a
commit
98d0eb7869
1 changed files with 8 additions and 0 deletions
|
|
@ -151,6 +151,10 @@ class PackedDict(dict):
|
|||
"assign item to this dict"
|
||||
super(PackedDict, self).__setitem__(*args, **kwargs)
|
||||
self.save()
|
||||
def __delitem__(self, *args, **kwargs):
|
||||
"delete with del self[key]"
|
||||
super(PackedDict, self).__delitem__(*args, **kwargs)
|
||||
self.save()
|
||||
def clear(self, *args, **kwargs):
|
||||
"Custom clear"
|
||||
super(PackedDict, self).clear(*args, **kwargs)
|
||||
|
|
@ -210,6 +214,10 @@ class PackedList(list):
|
|||
"Custom setitem that stores changed list to database."
|
||||
super(PackedList, self).__setitem__(*args, **kwargs)
|
||||
self.save()
|
||||
def __delitem__(self, *args, **kwargs):
|
||||
"delete with del self[index]"
|
||||
super(PackedList, self).__delitem__(*args, **kwargs)
|
||||
self.save()
|
||||
def append(self, *args, **kwargs):
|
||||
"Custom append"
|
||||
super(PackedList, self).append(*args, **kwargs)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue