Base class for aspects
Maps advice to members of a set of applied-to objects
Associate advice to given members
You cannot advise the same member twice for the same type of access, this implies that you cannot give advise to the special ‘*’ member and a regular member at the same for the same type of access.
A special member of ‘*’ is allowed for advising classes with metaclass=AOPMeta. This applies the advice to any member the applied object may have.
Check Advisor.is_advisable for further rules on what can be advised.
Parameters: |
|
---|
Apply the advice to the object
If already applied, do nothing
When obj is a class, the advice is applied to all instances of that class (and the class itself, for staticmethods and such)
Note: Advice given to a single instance always wraps/preceeds advice given to all instances, no matter what the order of applying was
Parameters: | obj (class, instance) – the object to advise. Cannot be a builtin object |
---|
Disable advice for given object
Aspect must have been applied to object, before you can disable.
When this aspect is unapplied to the object, it is automatically reenabled.
If obj was already disabled, do nothing.
Parameters: | obj (class, instance) – the object to advise |
---|
Enable advice for given object
Aspect must have been applied to object, before you can enable.
If obj was already enabled, do nothing.
Parameters: | obj (class, instance) – the object to advise |
---|
Get advice for member of obj.
Internal function (its interface may change in the future).
Parameters: |
|
---|---|
Returns: | advice func or None |
Get if this aspect is currently applied to an object.
See advisor.get_applied_aspects
Parameters: | obj (class, instance) – the object to advise |
---|---|
Returns: | True if aspect is in set of applied aspects of obj, False otherwise |
Get if this aspect is enabled for an object.
An aspect can be applied to an object but currently be disabled. Disabled aspects should not be asked for advice on that obj.
Parameters: | obj (class, instance) – the object to advise |
---|---|
Returns: | True if advice is currently enabled for and applied to obj, False otherwise |
Unapply the advice to the object
If advice wasn’t applied, do nothing
When obj is a class, the aspect is unapplied to all instances of that class (and the class itself).
Parameters: | obj (class, instance) – the object to advise |
---|
Base class for aspects
Maps advice to members of a set of applied-to objects
Apply the advice to the object
If already applied, do nothing
When obj is a class, the advice is applied to all instances of that class (and the class itself, for staticmethods and such)
Note: Advice given to a single instance always wraps/preceeds advice given to all instances, no matter what the order of applying was
Parameters: | obj (class, instance) – the object to advise. Cannot be a builtin object |
---|
Disable advice for given object
Aspect must have been applied to object, before you can disable.
When this aspect is unapplied to the object, it is automatically reenabled.
If obj was already disabled, do nothing.
Parameters: | obj (class, instance) – the object to advise |
---|
Enable advice for given object
Aspect must have been applied to object, before you can enable.
If obj was already enabled, do nothing.
Parameters: | obj (class, instance) – the object to advise |
---|
Get advice for member of obj.
Internal function (its interface may change in the future).
Parameters: |
|
---|---|
Returns: | advice func or None |
Get if this aspect is currently applied to an object.
See advisor.get_applied_aspects
Parameters: | obj (class, instance) – the object to advise |
---|---|
Returns: | True if aspect is in set of applied aspects of obj, False otherwise |
Get if this aspect is enabled for an object.
An aspect can be applied to an object but currently be disabled. Disabled aspects should not be asked for advice on that obj.
Parameters: | obj (class, instance) – the object to advise |
---|---|
Returns: | True if advice is currently enabled for and applied to obj, False otherwise |
Unapply the advice to the object
If advice wasn’t applied, do nothing
When obj is a class, the aspect is unapplied to all instances of that class (and the class itself).
Parameters: | obj (class, instance) – the object to advise |
---|