git://git.onelab.eu
/
plstackapi.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
83ba6fb
)
Cascading deletions for dependent objects
author
Sapan Bhatia
<sapanb@cs.princeton.edu>
Wed, 5 Nov 2014 05:14:02 +0000
(
00:14
-0500)
committer
Sapan Bhatia
<sapanb@cs.princeton.edu>
Wed, 5 Nov 2014 05:14:02 +0000
(
00:14
-0500)
planetstack/model_policy.py
patch
|
blob
|
history
diff --git
a/planetstack/model_policy.py
b/planetstack/model_policy.py
index
1262d26
..
7dc6dda
100644
(file)
--- a/
planetstack/model_policy.py
+++ b/
planetstack/model_policy.py
@@
-6,10
+6,14
@@
from dependency_walker import *
import model_policies
def update_dep(d, o):
- print "Updating %s (%s)"%(d,d.__class__.__name__)
if (d.updated < o.updated):
d.save(update_fields=['updated'])
+def delete_if_inactive(d, o):
+ #print "Deleting %s (%s)"%(d,d.__class__.__name__)
+ d.delete()
+ return
+
@receiver(post_save)
def post_save_handler(sender, instance, **kwargs):
sender_name = sender.__name__
@@
-27,4
+31,6
@@
def post_save_handler(sender, instance, **kwargs):
except:
pass
+ elif 'deleted' in kwargs['update_fields']:
+ walk_inv_deps(delete_if_inactive, instance)