Handy base class for aspects.
You don’t have to use this base class for your aspects, but you’ll probably find it helpful to do so.
Aspects should adhere to this interface.
Aspects can be applied at most once to the same object.
Create the aspect
Add advice to give.
The order in which advise is given is important. Last added advise is called first. Put differently, added advise wraps previous advise of given members.
A special member of ‘*’ is allowed as well for advising classes with metaclass=AOPMeta. This applies the advice to any member of obj. This advice preceeds other advice (though instance * advice is still preceded by any class advice).
Parameters: |
|
---|
Apply the advice to the object
If already applied, do nothing
Parameters: |
|
---|
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: |
|
---|
Enable advice for given object
Aspect must have been applied to object, before you can enable.
If obj was already enabled, do nothing.
Parameters: |
|
---|
Get iter of advice for member of obj.
Internal function (its interface may change in the future).
Parameters: |
|
---|---|
Returns: | advice funcs, the left is the first advice to give (i.e. the last advice given; the most outer advice) |
Return type: | iter([advice, generator]...) |
Get if this aspect is currently applied to an object.
Parameters: |
|
---|---|
Returns: | True if advice is currently applied to 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: |
|
---|---|
Returns: | True if advice is currently enabled for obj, False otherwise |
Unapply the advice to the object
If advice wasn’t applied, do nothing
Parameters: |
|
---|
list of weak references to the object (if defined)