networkapi.models package¶
Submodules¶
networkapi.models.BaseManager module¶
-
class
networkapi.models.BaseManager.
BaseManager
[source]¶ Bases:
django.db.models.manager.Manager
Base class for managing the operations to database
-
class
networkapi.models.BaseManager.
BaseQuerySet
(model=None, query=None, using=None)[source]¶ Bases:
django.db.models.query.QuerySet
Base class for operations to database
-
for_update
()[source]¶ Returns query, rewrited to use SELECT … FOR UPDATE. Can be used in transaction to get lock on selected rows. Database must support this SQL statements.
Example: >>> query = MyModel.objects.filter(name = ‘mateus’).for_update() >>> unicode(query.query) “SELECT * FROM myapp_mymodel WHERE name = ‘mateus’ FOR UPDATE”
-
networkapi.models.BaseModel module¶
-
class
networkapi.models.BaseModel.
BaseModel
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
Classe básica para as classes que herdam de “django.db.models.Model”.
Deverão herdar desta classe as classes “Model” que necessitam gerar log das suas operações de escrita e exclusão de dados no banco de dados.
-
delete
(*args, **kwargs)[source]¶ Replace super(BaseModel, self).delete() Cause: When delete relationship in cascade default no have attribute User to Log.
-
objects
¶
-
networkapi.models.models_signal_receiver module¶
-
networkapi.models.models_signal_receiver.
audit_post_save
(sender, instance, created, **kwargs)[source]¶
-
networkapi.models.models_signal_receiver.
get_cache_key_for_instance
(instance, cache_prefix='networkapi_event_log')[source]¶
-
networkapi.models.models_signal_receiver.
get_value
(obj, attr)[source]¶ Returns the value of an attribute. First it tries to return the unicode value.
-
networkapi.models.models_signal_receiver.
save_audit
(instance, operation, kwargs={})[source]¶ Saves the audit. However, the variable persist_audit controls if the audit should be really saved to the database or not. This variable is only affected in a change operation. If no change is detected than it is setted to False.
Keyword arguments: instance – instance operation – operation type (add, change, delete) kwargs – kwargs dict sent from m2m signal