Base class for aspects
Maps advice to members of a set of applied-to objects
Mappings of (access, attribute_name) to advice to give or None, where access is either ‘get’, ‘set’, ‘delete’ or ‘call’. Default value is {}.
Check Advisor.is_advisable for rules on valid attribute_name’s
Boolean that indicates whether or not advice mappings has a sensible result for keys(). Default is False.
Some mappings do not support keys because their set of keys is infinite or hard to determine. (FunctionMap is an example of such Mappings)
If set to True, the aspect can only be applied to objects with AOPMeta as metaclass.
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 attribute of obj.
Internal function
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 attribute of obj.
Internal function
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 |
---|