def _on_delete model properties def on_delete instance print Hoho some

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
def _on_delete(model, properties):
def on_delete(instance):
print 'Hoho, somebody wants to delete instance of model %s' % model
#for property in properties:
#Task.objects.get(content_type=ContentType.objects.get_for_model(instance),
#object_id=instance.id,
#property=property).delete()
return on_delete
def patch(sender):
model = sender
#print model
if hasattr(model, 'Task'):
#print 'model %s has Task attribute' % model
if hasattr(model.Task, 'fields'):
for field in model.Task.fields:
model.add_to_class('%s_task' % field, property(_property_task(field)))
model.add_to_class('save', _save(getattr(model, 'save'), field))
print 'Ok, let\'s create pre_delete handler for model %s' % model
dispatcher.connect(_on_delete(model, model.Task.fields), sender=model, signal=signals.pre_delete)