noc.core.model.decorator

Module Contents

noc.core.model.decorator._get_field_snapshot(sender, instance)
noc.core.model.decorator._on_model_save_handler(sender, instance, *args, **kwargs)
noc.core.model.decorator._on_document_save_handler(sender, document, *args, **kwargs)
noc.core.model.decorator.on_save(cls)
Class decorator connecting django's post_save signal
to models's on_save method. When used in conjuction with
@on_init decorator, *changed_field* attribute is available

Usage

@on_save class MyModel(Model):

… def on_save(self):

noc.core.model.decorator._on_model_delete_handler(sender, instance, *args, **kwargs)
noc.core.model.decorator._on_document_delete_handler(sender, document, *args, **kwargs)
noc.core.model.decorator.on_delete(cls)
Class decorator connecting django's post_save signal
to models's on_delete method.

Usage

@on_delete class MyModel(Model):

… def on_delete(self):

noc.core.model.decorator._on_init_handler(sender, instance, *args, **kwargs)
noc.core.model.decorator.on_init(cls)
Class decorator storing initial model data into
.initial_data attribute.

@on_init class MyModel(Model):

… def my_method(self):

… print self.initial_data …
noc.core.model.decorator.on_delete_check(check=None, clean=None, delete=None, ignore=None)
Class decorator to check and process constraints before
trying to delete documents
@on_delete_check(

# Raise ValueError if related documents contain any records check=[

], # Replace model.field value with None clean=[

(“model”, “field”), …

], # Remove records referred by deleted one delete=[

(“model”, “field”)

], # Ignore checks ignore=[

(“model”, “field”)

]

)

Returns: